Use new alias system with brew search
Also don't show any aliases if you just type `brew search` as there is so little context, it just looks messy.
This commit is contained in:
parent
0fcb584862
commit
dad4bbb9e3
@ -410,18 +410,24 @@ end
|
|||||||
|
|
||||||
def search_brews text
|
def search_brews text
|
||||||
require "formula"
|
require "formula"
|
||||||
formulae = Formulary.names with_aliases=true
|
|
||||||
if text =~ /^\/(.*)\/$/
|
return Formula.names if text.to_s.empty?
|
||||||
results = formulae.grep(Regexp.new($1))
|
|
||||||
|
rx = if text =~ %r{^/(.*)/$}
|
||||||
|
Regexp.new($1)
|
||||||
else
|
else
|
||||||
search_term = Regexp.escape(text || "")
|
/.*#{Regexp.escape text}.*/i
|
||||||
results = formulae.grep(/.*#{search_term}.*/)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
aliases = Formula.aliases
|
||||||
|
results = (Formula.names+aliases).grep rx
|
||||||
|
|
||||||
# Filter out aliases when the full name was also found
|
# Filter out aliases when the full name was also found
|
||||||
aliases = Formulary.get_aliases
|
results.reject do |alias_name|
|
||||||
return results.select do |r|
|
if aliases.include? alias_name
|
||||||
aliases[r] == nil or not (results.include? aliases[r])
|
resolved_name = (HOMEBREW_REPOSITORY+"Library/Aliases/#{alias_name}").readlink.basename('.rb').to_s
|
||||||
|
results.include? resolved_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user