]> arthur.barton.de Git - brew-completion.git/blobdiff - brew-completion.sh
Added support for external brew commands stored in /usr/local/bin
[brew-completion.git] / brew-completion.sh
index 0934cff9aea01cb43b15c7b132de9eb10fb66b13..e72353479d2351c57f254bbd8331b94c6a00bcab 100644 (file)
@@ -30,6 +30,10 @@ _brew()
        prev=${COMP_WORDS[COMP_CWORD-1]}
        cmd=""
 
+       # Get list of all available external commands
+       EXTCMD=`cd /usr/local/bin; ls -1 brew-* | cut -d'.' -f1 \
+               | cut -d'-' -f2- | sed -e 's/\*//g'`
+
        declare -i i=$COMP_CWORD-1
        while [ $i -gt 0 ]; do
                if [[ ${COMP_WORDS[i]} != -* \
@@ -91,6 +95,13 @@ _brew()
                "search"|"update")
                        return 0
                        ;;
+               *)
+                       for c in $EXTCMD; do
+                               if [ "$cmd" = "$c" ]; then
+                                       _brew_formula "$cur"
+                                       return 0
+                               fi
+                       done
        esac
 
        if [[ "$cur" == -* ]]; then
@@ -99,7 +110,7 @@ _brew()
        elif [ "$cmd" = "" ]; then
                COMPREPLY=( $(compgen -W 'cleanup create edit home info \
                        install link list log outdated prune remove search \
-                       uninstall unlink update' -- "$cur") )
+                       uninstall unlink update $EXTCMD' -- "$cur") )
        fi
 }
 complete -F _brew brew