aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJustin Hileman2011-02-05 09:33:49 -0500
committerAdam Vandenberg2011-02-09 17:44:01 -0800
commit3c25722e51430189f83c2ca9b6896032708d0ad4 (patch)
tree60cd3b0ec7522c084853f107fd3376f57f9ab3c6 /Library
parent3a05e0854ef724cd0548604f3bfbc6daf9e98f8b (diff)
downloadhomebrew-3c25722e51430189f83c2ca9b6896032708d0ad4.tar.bz2
Handle default install --options
i.e. `--force --debug --use-llvm --ignore-dependencies --HEAD` Additionally: * Use a cleaner `if` block in install options completion case. * De-dupe options for subsequent completion (e.g. stop offering --foo once --foo option has been used). Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/brew_bash_completion.sh23
1 files changed, 20 insertions, 3 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh
index 6fc3465f2..d219bd518 100644
--- a/Library/Contributions/brew_bash_completion.sh
+++ b/Library/Contributions/brew_bash_completion.sh
@@ -29,6 +29,17 @@ _brew_to_completion()
case "$prev" in
# Commands that take a formula
cat|deps|edit|fetch|home|homepage|info|install|log|options|uses)
+ # handle standard --options
+ if [[ "$prev" == "install" && "$cur" == --* ]]; then
+ local opts=$(
+ local opts=( --force --debug --use-llvm --ignore-dependencies --HEAD )
+ for o in ${opts[*]}; do
+ [[ " ${COMP_WORDS[*]} " =~ " $o " ]] || echo "$o"
+ done
+ )
+ COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
+ return
+ fi
local ff=$(\ls $(brew --repository)/Library/Formula | sed "s/\.rb//g")
local af=$(\ls $(brew --repository)/Library/Aliases 2> /dev/null | sed "s/\.rb//g")
COMPREPLY=( $(compgen -W "${ff} ${af}" -- ${cur}) )
@@ -41,10 +52,16 @@ _brew_to_completion()
;;
# Complete --options for selected brew
*)
- [[ ${COMP_WORDS[1]} == "install" ]] && [[ "$cur" == --* ]] && {
- COMPREPLY=( $(compgen -W "$(brew options --compact "$prev")" -- ${cur}) )
+ if [[ ${COMP_WORDS[1]} == "install" && "$cur" == --* ]]; then
+ local opts=$(
+ local opts=( $(brew options --compact "$prev") )
+ for o in ${opts[*]}; do
+ [[ " ${COMP_WORDS[*]} " =~ " $o " ]] || echo "$o"
+ done
+ )
+ COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return
- }
+ fi
;;
esac
}