X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=brew-completion.sh;h=0934cff9aea01cb43b15c7b132de9eb10fb66b13;hb=cb3eec15b3a8c7448497dde44f31ca53583b8fc3;hp=c0c0e4e8d20917b2fa43bf212c4d2e6f60694db6;hpb=bdd69d18e9512162180fcdd3235d76060e86c718;p=brew-completion.git diff --git a/brew-completion.sh b/brew-completion.sh index c0c0e4e..0934cff 100644 --- a/brew-completion.sh +++ b/brew-completion.sh @@ -1,5 +1,5 @@ # brew-completion: bash completion function for Homebrew (brew command) -# Copyright (c)1020 Alexander Barton +# Copyright (c)2010 Alexander Barton # This is free software and published under the terms of the GNU # General Public License, see the file COPYING for details. @@ -8,9 +8,7 @@ _brew_formula() local formulae prefix prefix=`brew --prefix` - pushd "$prefix"/Library/Formula >/dev/null - formulae=`echo * | sed 's/\.rb//g'` - popd >/dev/null + formulae=`brew search` COMPREPLY=( $(compgen -W '$formulae' -- "$1") ) } @@ -19,9 +17,7 @@ _brew_formula_installed() local formulae prefix prefix=`brew --prefix` - pushd "$prefix"/Cellar >/dev/null - formulae=`echo *` - popd >/dev/null + formulae=`brew list` COMPREPLY=( $(compgen -W '$formulae' -- "$1") ) } @@ -36,7 +32,10 @@ _brew() declare -i i=$COMP_CWORD-1 while [ $i -gt 0 ]; do - if [[ ${COMP_WORDS[i]} != -* ]]; then + if [[ ${COMP_WORDS[i]} != -* \ + || ${COMP_WORDS[i]} == "--cache" \ + || ${COMP_WORDS[i]} == "--cellar" \ + || ${COMP_WORDS[i]} == "--prefix" ]]; then cmd=${COMP_WORDS[i]} break fi @@ -44,7 +43,8 @@ _brew() done case "$cmd" in - "edit"|"home"|"log"|"prune") + "cleanup"|"edit"|"home"|"log"|"prune" \ + |"--cache"|"--cellar"|"--prefix") _brew_formula "$cur" return 0 ;; @@ -81,7 +81,7 @@ _brew() ;; "list") if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--brewed \ + COMPREPLY=( $(compgen -W ' --unbrewed' -- "$cur") ) else _brew_formula "$cur" @@ -94,12 +94,12 @@ _brew() esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--cache --help --prefix --version \ - -v -H' -- "$cur") ) + COMPREPLY=( $(compgen -W '--cache --cellar --help --prefix \ + --version -v -H' -- "$cur") ) elif [ "$cmd" = "" ]; then - COMPREPLY=( $(compgen -W 'create edit home info install \ - link list log prune remove search uninstall unlink \ - update' -- "$cur") ) + COMPREPLY=( $(compgen -W 'cleanup create edit home info \ + install link list log outdated prune remove search \ + uninstall unlink update' -- "$cur") ) fi } complete -F _brew brew