From 47d24c461c3ec6db5c75f2ccdefb2f8ad9998119 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 14 Apr 2014 22:32:24 -0500 Subject: [PATCH] Do path and string manipulation in pure bash --- Library/Contributions/brew_bash_completion.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh index e0cda943a7..5f7a45db51 100644 --- a/Library/Contributions/brew_bash_completion.sh +++ b/Library/Contributions/brew_bash_completion.sh @@ -61,14 +61,18 @@ __brew_complete_formulae () { local cur="${COMP_WORDS[COMP_CWORD]}" local lib=$(brew --repository)/Library + local taps=${lib}/Taps local ff=$(\ls ${lib}/Formula 2>/dev/null | sed 's/\.rb//g') local af=$(\ls ${lib}/Aliases 2>/dev/null) - local tf tap + local tf file - for dir in $(\ls ${lib}/Taps 2>/dev/null); do - tap="$(echo "$dir" | sed 's|-|/|g')" - tf="$tf $(\ls -1R "${lib}/Taps/${dir}" 2>/dev/null | - grep '.\+.rb' | sed -E 's|(.+)\.rb|'"${tap}"'/\1|g')" + for file in ${taps}/*/*.rb ${taps}/*/Formula/*.rb ${taps}/*/HomebrewFormula/*.rb; do + file=${file/"Formula/"/} + file=${file/"HomebrewFormula/"/} + file=${file#${lib}/Taps/} + file=${file%.rb} + file=${file/-//} + tf="${tf} ${file}" done COMPREPLY=($(compgen -W "$ff $af $tf" -- "$cur"))