Skip to content

Commit 486d3d8

Browse files
committed
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.
1 parent cfc4019 commit 486d3d8

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

Library/Homebrew/dev-cmd/edit.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def edit
2121
# If no brews are listed, open the project root in an editor.
2222
if ARGV.named.empty?
2323
editor = File.basename which_editor
24-
if ["mate", "subl"].include?(editor)
25-
# If the user is using TextMate or Sublime Text,
24+
if ["atom", "subl", "mate"].include?(editor)
25+
# If the user is using Atom, Sublime Text or TextMate
2626
# give a nice project view instead.
2727
exec_editor HOMEBREW_REPOSITORY/"bin/brew",
2828
HOMEBREW_REPOSITORY/"README.md",

Library/Homebrew/utils.rb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,16 @@ def which_all(cmd, path = ENV["PATH"])
328328
end
329329

330330
def which_editor
331-
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL").compact.reject(&:empty?).first
332-
return editor unless editor.nil?
333-
334-
# Find Textmate, BBEdit / TextWrangler, or vim
335-
%w[mate edit vim].each do |candidate|
336-
editor = candidate if which(candidate, ENV["HOMEBREW_PATH"])
331+
editor = ENV.values_at("HOMEBREW_EDITOR", "HOMEBREW_VISUAL")
332+
.compact
333+
.reject(&:empty?)
334+
.first
335+
return editor if editor
336+
337+
# Find Atom, Sublime Text, Textmate, BBEdit / TextWrangler, or vim
338+
editor = %w[atom subl mate edit vim].find do |candidate|
339+
candidate if which(candidate, ENV["HOMEBREW_PATH"])
337340
end
338-
339-
# Find Textmate
340-
editor = which("mate", ENV["HOMEBREW_PATH"])
341-
# Find BBEdit/TextWrangler
342-
editor ||= which("edit", ENV["HOMEBREW_PATH"])
343-
# Find vim
344-
editor ||= which("vim", ENV["HOMEBREW_PATH"])
345-
# Default to standard vim
346341
editor ||= "/usr/bin/vim"
347342

348343
opoo <<-EOS.undent

0 commit comments

Comments
 (0)