diff options
| author | Adam Vandenberg | 2010-02-27 16:51:12 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2010-02-27 19:33:10 -0800 |
| commit | 1ade7ef4e0d5c11fd4c8720f9268d23ff3db1e90 (patch) | |
| tree | df7646387c157878b8697a667b2815e6cc4a3963 /Library | |
| parent | 70bfe518ec6ca66072a6b101631cc104c359153a (diff) | |
| download | brew-1ade7ef4e0d5c11fd4c8720f9268d23ff3db1e90.tar.bz2 | |
Update bash completions
* Bring command list up-to-date
* Subcommand completion now ignores switches
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Contributions/brew_bash_completion.sh | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh index 86dbde5bf..ae5342a81 100644 --- a/Library/Contributions/brew_bash_completion.sh +++ b/Library/Contributions/brew_bash_completion.sh @@ -5,27 +5,35 @@ _brew_to_completion() { - local actions cur prev + local actions cur prev prev_index local cellar_contents formulae which_cellar brew_base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" # We only complete unabbreviated commands... - actions="cleanup configure create deps edit generate homepage info install list link options prune remove search unlink update uses" + actions="cat cleanup configure create deps edit generate homepage info install list link outdated prune remove search unlink update uses" - # Subcommand list if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then + # Subcommand list COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) ) return 0 - # Subcommands else + # Subcommands brew_base=`brew --repository` + # We want the non-switch previous word + prev_index=$((COMP_CWORD - 1)) + prev="${COMP_WORDS[prev_index]}" + while [[ $prev == -* ]] + do + prev_index=$((prev_index - 1)) + prev="${COMP_WORDS[prev_index]}" + done + case ${prev} in # Commands that take a formula... - deps|edit|install|home|homepage|uses) + cat|deps|edit|install|home|homepage|uses) formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"` COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) ) return 0 |
