From: Alexander Barton Date: Tue, 22 Jun 2010 15:59:21 +0000 (+0200) Subject: Added support for external brew commands stored in /usr/local/bin X-Git-Url: https://arthur.ath.cx/gitweb/?a=commitdiff_plain;h=8a544f401b71c006992c5cf25482e1c03a8d6572;p=brew-completion.git Added support for external brew commands stored in /usr/local/bin --- diff --git a/brew-completion.sh b/brew-completion.sh index 0934cff..e723534 100644 --- a/brew-completion.sh +++ b/brew-completion.sh @@ -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