edit: tweak default editors.

Add `atom` (not my editor of choice [TextMate for life!]) but widely
used enough to probably warrant it. Also, reorder based on my best
guestimates of current usage and cleanup the editor code while we're
here.
This commit is contained in:
Mike McQuaid 2017-06-07 16:07:40 +01:00
parent cfc40196f2
commit 486d3d84b1
2 changed files with 10 additions and 15 deletions

View File

@ -21,8 +21,8 @@ module Homebrew
# If no brews are listed, open the project root in an editor. # If no brews are listed, open the project root in an editor.
if ARGV.named.empty? if ARGV.named.empty?
editor = File.basename which_editor editor = File.basename which_editor
if ["mate", "subl"].include?(editor) if ["atom", "subl", "mate"].include?(editor)
# If the user is using TextMate or Sublime Text, # If the user is using Atom, Sublime Text or TextMate
# give a nice project view instead. # give a nice project view instead.
exec_editor HOMEBREW_REPOSITORY/"bin/brew", exec_editor HOMEBREW_REPOSITORY/"bin/brew",
HOMEBREW_REPOSITORY/"README.md", HOMEBREW_REPOSITORY/"README.md",

View File

@ -328,21 +328,16 @@ def which_all(cmd, path = ENV["PATH"])
end end
def which_editor def which_editor
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL")
return editor unless editor.nil? .compact
.reject(&:empty?)
.first
return editor if editor
# Find Textmate, BBEdit / TextWrangler, or vim # Find Atom, Sublime Text, Textmate, BBEdit / TextWrangler, or vim
%w[mate edit vim].each do |candidate| editor = %w[atom subl mate edit vim].find do |candidate|
editor = candidate if which(candidate, ENV["HOMEBREW_PATH"]) candidate if which(candidate, ENV["HOMEBREW_PATH"])
end end
# Find Textmate
editor = which("mate", ENV["HOMEBREW_PATH"])
# Find BBEdit/TextWrangler
editor ||= which("edit", ENV["HOMEBREW_PATH"])
# Find vim
editor ||= which("vim", ENV["HOMEBREW_PATH"])
# Default to standard vim
editor ||= "/usr/bin/vim" editor ||= "/usr/bin/vim"
opoo <<-EOS.undent opoo <<-EOS.undent