From e23a612c4d3d4771e43873fef4bb4281ea6cc7da Mon Sep 17 00:00:00 2001 From: scoates Date: Sat, 5 Sep 2009 14:03:41 -0400 Subject: 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 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. --- Library/Homebrew/utils.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Library') 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 -- cgit v1.2.3