aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorscoates2009-09-05 14:03:41 -0400
committerMax Howell2009-09-05 19:10:56 +0100
commit7709c3699a5e01f01abee08c8fec59ce57eceeb7 (patch)
tree4a393b31a3359dd52e85e4f5fd2c1d029e9e7130 /Library/Homebrew/utils.rb
parentc7976fcca2763ec7586a723c32c91688f76a2657 (diff)
downloadbrew-7709c3699a5e01f01abee08c8fec59ce57eceeb7.tar.bz2
Use ENV[EDITOR] if possible
Defaulting to EDITOR, then checking for the mate command, and then using vim as a last resort. Signed Off By: Max Howell <max@methylblue.com> Plain brew edit still uses Textmate though because a client that supported a project concept is required for that particular feature. Patches for that welcome.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 8bd2537e5..0dd26d49b 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -80,3 +80,15 @@ def puts_columns items, cols = 4
width=`stty size`.chomp.split(" ").last
IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
end
+
+def exec_editor *args
+ editor=ENV['EDITOR']
+ if editor.nil?
+ if system "which -s mate" and $?.success?
+ editor='mate'
+ else
+ editor='vim'
+ end
+ end
+ exec editor, *args
+end