Speed up tab completion

Fixes #20. Closes #23.
This commit is contained in:
tim smith 2016-04-05 09:48:28 -07:00
parent fad235d8e8
commit 3afacc351c

View File

@ -45,23 +45,9 @@ __brewcomp ()
__brew_complete_formulae () __brew_complete_formulae ()
{ {
local cur="${COMP_WORDS[COMP_CWORD]}" local cur="${COMP_WORDS[COMP_CWORD]}"
local lib=$(brew --repository)/Library local formulas="$(brew search)"
local taps=${lib}/Taps local shortnames="$(echo "$formulas" | grep / | cut -d / -f 3)"
local ff=$(\ls ${lib}/Formula 2>/dev/null | sed 's/\.rb//g') COMPREPLY=($(compgen -W "$formulas $shortnames" -- "$cur"))
local af=$(\ls ${lib}/Aliases 2>/dev/null)
local tf file
for file in ${taps}/*/*/*.rb ${taps}/*/*/Formula/*.rb ${taps}/*/*/HomebrewFormula/*.rb; do
[ -f "$file" ] || continue
file=${file/"Formula/"/}
file=${file/"HomebrewFormula/"/}
file=${file#${lib}/Taps/}
file=${file%.rb}
file=${file/homebrew-/}
tf="${tf} ${file}"
done
COMPREPLY=($(compgen -W "$ff $af $tf" -- "$cur"))
} }
__brew_complete_installed () __brew_complete_installed ()