add which method

This commit is contained in:
Adam Vandenberg 2012-03-03 15:50:24 -08:00
parent 6868bf0d6e
commit cc78050dc5

View File

@ -138,6 +138,15 @@ def puts_columns items, star_items=[]
end end
end end
def which cmd
path = `/usr/bin/which #{cmd}`.chomp
if path.empty?
nil
else
Pathname.new(path)
end
end
def which_editor def which_editor
editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR'] editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR']
# If an editor wasn't set, try to pick a sane default # If an editor wasn't set, try to pick a sane default