diff options
| author | Adam Vandenberg | 2011-12-16 14:27:58 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2011-12-16 14:27:58 -0800 |
| commit | 62e1dd8bd5f227bc3d56cf253d5bdc88aefb2496 (patch) | |
| tree | 0b56db12dba094e62c633db4765d3e7889f23986 /Library/Homebrew/utils.rb | |
| parent | df8edc94d6237cc58e8eb51d537c7ddb18687e98 (diff) | |
| download | brew-62e1dd8bd5f227bc3d56cf253d5bdc88aefb2496.tar.bz2 | |
Enable 'brew edit' for non-Textmate editors.
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 6d4d8c237..adf9c8d10 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -137,24 +137,26 @@ def puts_columns items, star_items=[] end end +def which_editor + editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR'] + # If an editor wasn't set, try to pick a sane default + return editor unless editor.nil? + + # Find Textmate + return 'mate' if system "/usr/bin/which -s mate" + # Find # BBEdit / TextWrangler + return 'edit' if system "/usr/bin/which -s edit" + # Default to vim + return '/usr/bin/vim' +end + def exec_editor *args return if args.to_s.empty? - editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR'] - if editor.nil? - editor = if system "/usr/bin/which -s mate" - 'mate' - elsif system "/usr/bin/which -s edit" - 'edit' # BBEdit / TextWrangler - else - '/usr/bin/vim' # Default to vim - end - end - # Invoke bash to evaluate env vars in $EDITOR # This also gets us proper argument quoting. # See: https://github.com/mxcl/homebrew/issues/5123 - system "bash", "-c", editor + ' "$@"', "--", *args + system "bash", "-c", which_editor + ' "$@"', "--", *args end # GZips the given paths, and returns the gzipped paths |
