aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorscoates2009-09-05 14:03:41 -0400
committerMax Howell2009-09-05 19:10:56 +0100
commite23a612c4d3d4771e43873fef4bb4281ea6cc7da (patch)
tree12e6c3dbbfa1eaa608d77cab18f722def214207a /Library
parent4d25f7bd13f3b4a4c527593e73de61b531756d28 (diff)
downloadhomebrew-e23a612c4d3d4771e43873fef4bb4281ea6cc7da.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')
-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