X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=brew-completion.sh;h=c14827b09bc6121bcc34d6c68eb85aa743f06a67;hb=a94ee902a2ef6e2ac0b5fd3269cfee2314424ae1;hp=4a55b27b6fdeea566df3b9d391289952893e511d;hpb=ddc883a695610383fe54873991c748ccc69b1892;p=brew-completion.git diff --git a/brew-completion.sh b/brew-completion.sh index 4a55b27..c14827b 100644 --- a/brew-completion.sh +++ b/brew-completion.sh @@ -30,9 +30,17 @@ _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]} != -* ]]; then + if [[ ${COMP_WORDS[i]} != -* \ + || ${COMP_WORDS[i]} == "--cache" \ + || ${COMP_WORDS[i]} == "--cellar" \ + || ${COMP_WORDS[i]} == "--config" \ + || ${COMP_WORDS[i]} == "--prefix" ]]; then cmd=${COMP_WORDS[i]} break fi @@ -40,24 +48,25 @@ _brew() done case "$cmd" in - "cleanup"|"edit"|"home"|"log"|"prune") + "cat"|"cleanup"|"deps"|"edit"|"home"|"log"|"prune"|"uses" \ + |"--cache"|"--cellar"|"--prefix") _brew_formula "$cur" return 0 ;; - "link"|"remove"|"uninstall"|"unlink") + "link"|"remove"|"rm"|"uninstall"|"unlink") _brew_formula_installed "$cur" return 0 ;; "create") if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--macports' \ - -- "$cur") ) + COMPREPLY=( $(compgen -W '--macports --fink \ + --cache' -- "$cur") ) fi return 0 ;; "info") if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--github' \ + COMPREPLY=( $(compgen -W '--all --github' \ -- "$cur") ) else _brew_formula "$cur" @@ -66,9 +75,10 @@ _brew() ;; "install") if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--HEAD -H \ - --debug -d --interactive -i - --verbose -v --ignore-dependencies' \ + COMPREPLY=( $(compgen -W '--git --HEAD -H \ + --debug -d --force -f \ + --interactive -i --verbose -v \ + --ignore-dependencies --use-llvm' \ -- "$cur") ) else _brew_formula "$cur" @@ -77,25 +87,32 @@ _brew() ;; "list") if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--brewed \ + COMPREPLY=( $(compgen -W ' --unbrewed' -- "$cur") ) else _brew_formula "$cur" fi return 0 ;; - "search"|"update") - return 0 - ;; + *) + for c in $EXTCMD; do + if [ "$cmd" = "$c" ]; then + _brew_formula "$cur" + return 0 + fi + done esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--cache --help --prefix --version \ - -v -H' -- "$cur") ) + COMPREPLY=( $(compgen -W '--cache --cellar --config \ + --help --prefix --version -v -H' \ + -- "$cur") ) elif [ "$cmd" = "" ]; then - COMPREPLY=( $(compgen -W 'cleanup create edit home info \ - install link list log prune remove search uninstall \ - unlink update' -- "$cur") ) + COMPREPLY=( $(compgen -W 'cat cleanup create deps doctor \ + edit home info install link list log outdated prune \ + remove rm search uninstall unlink up update uses \ + $EXTCMD' \ + -- "$cur") ) fi } complete -F _brew brew