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.
This commit is contained in:
parent
c7976fcca2
commit
7709c3699a
@ -80,3 +80,15 @@ def puts_columns items, cols = 4
|
|||||||
width=`stty size`.chomp.split(" ").last
|
width=`stty size`.chomp.split(" ").last
|
||||||
IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
|
IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
|
||||||
end
|
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
|
||||||
|
|||||||
11
bin/brew
11
bin/brew
@ -34,7 +34,7 @@ end
|
|||||||
if Hardware.cpu_type == :ppc or Hardware.cpu_type == :dunno
|
if Hardware.cpu_type == :ppc or Hardware.cpu_type == :dunno
|
||||||
abort "Sorry, Homebrew does not support your computer's CPU architecture."
|
abort "Sorry, Homebrew does not support your computer's CPU architecture."
|
||||||
end
|
end
|
||||||
unless system "which gcc-4.2 &> /dev/null" and $?.success?
|
unless system "which -s gcc-4.2" and $?.success?
|
||||||
abort "Sorry, Homebrew requires gcc 4.2, which is provided by Xcode 3.1"
|
abort "Sorry, Homebrew requires gcc 4.2, which is provided by Xcode 3.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -66,11 +66,14 @@ begin
|
|||||||
|
|
||||||
when 'edit'
|
when 'edit'
|
||||||
if ARGV.named_empty?
|
if ARGV.named_empty?
|
||||||
exec "mate", *Dir["#{HOMEBREW_PREFIX}/Library/*"]<<
|
# EDITOR isn't a good fit here, we need a GUI client that actually has
|
||||||
|
# a UI for projects, so apologies if this wasn't what you expected,
|
||||||
|
# please improve it! :)
|
||||||
|
exec 'mate', *Dir["#{HOMEBREW_PREFIX}/Library/*"]<<
|
||||||
"#{HOMEBREW_PREFIX}/bin/brew"<<
|
"#{HOMEBREW_PREFIX}/bin/brew"<<
|
||||||
"#{HOMEBREW_PREFIX}/README"
|
"#{HOMEBREW_PREFIX}/README"
|
||||||
else
|
else
|
||||||
exec "mate", *ARGV.formulae.collect {|f| f.path}
|
exec_editor *ARGV.formulae.collect {|f| f.path}
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'install'
|
when 'install'
|
||||||
@ -179,7 +182,7 @@ begin
|
|||||||
if ARGV.include? '--macports'
|
if ARGV.include? '--macports'
|
||||||
exec "open", "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
|
exec "open", "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
|
||||||
else
|
else
|
||||||
exec "mate", *ARGV.collect {|name| make name}
|
exec_editor *ARGV.collect {|name| make name}
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'diy', 'configure'
|
when 'diy', 'configure'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user