aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharlie Sharpsteen2011-08-17 22:43:57 -0700
committerAdam Vandenberg2011-08-17 23:23:20 -0700
commita36ae37d4ba55c11dd8f50f3194968cfd8ab7511 (patch)
tree5c29fe75b1db8b0245ed8a334c05ee44ea18833a
parent22c44ac36123d22429816b2444698be5b3888a8f (diff)
downloadhomebrew-a36ae37d4ba55c11dd8f50f3194968cfd8ab7511.tar.bz2
Contribution: Tweak bash completion for install
Selection of generic installation options, such as `--HEAD`, is now lumped together with selection of formulae-specific options. This allows any installation option to be tab-completed *before or after* the formula name is specified. Signed-off-by: Adam Vandenberg <flangy@gmail.com>
-rw-r--r--Library/Contributions/brew_bash_completion.sh39
1 files changed, 15 insertions, 24 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh
index 383a53e60..246cd3968 100644
--- a/Library/Contributions/brew_bash_completion.sh
+++ b/Library/Contributions/brew_bash_completion.sh
@@ -26,20 +26,24 @@ _brew_to_completion()
prev="${COMP_WORDS[prev_index]}"
done
+ # Handle installation --options
+ if [[ ${COMP_WORDS[1]} == "install" && "$cur" == --* ]]; then
+ local opts=$(
+ local opts=(
+ --force --verbose --debug --use-clang --use-gcc --use-llvm --ignore-dependencies --HEAD
+ $(brew options --compact "$prev")
+ )
+ for o in ${opts[*]}; do
+ [[ " ${COMP_WORDS[*]} " =~ " $o " ]] || echo "$o"
+ done
+ )
+ COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
+ return
+ fi
+
case "$prev" in
# Commands that take a formula
cat|deps|edit|fetch|home|homepage|info|install|log|missing|options|uses|versions)
- # handle standard --options
- if [[ "$prev" == "install" && "$cur" == --* ]]; then
- local opts=$(
- local opts=( --force --verbose --debug --use-clang --use-gcc --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}) )
@@ -50,19 +54,6 @@ _brew_to_completion()
COMPREPLY=( $(compgen -W "$(\ls $(brew --cellar))" -- ${cur}) )
return
;;
- # Complete --options for selected brew
- *)
- 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
}