aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2011-12-11 01:29:15 -0600
committerJack Nagel2011-12-11 01:49:47 -0600
commit96da368fc5a3ff4edcbb7fab6d6dc789c565ed85 (patch)
tree545d514cff36802d4dbdda430f15fae6f7977b66 /Library
parent7cf07cb2b6f3eac5b14600c9e829498bfd42574c (diff)
downloadhomebrew-96da368fc5a3ff4edcbb7fab6d6dc789c565ed85.tar.bz2
completion: complete multiple formula arguments
We make the assumption that the first non-option word is the command being invoked. Originally I was trying to allow command completion for non-standard command lines like $ brew --verbose inst<TAB> but right now executing something like that doesn't actually work. Which is interesting, because the man page implies that it should. Either the man page is incorrect, or something was broken between then and now. Anyway, it would probably be safe to just assume that COMP_WORDS[1] is the command, and we do make that assumption in other places. But if we ever do allow things like "brew --option command", this will be useful. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/brew_bash_completion.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh
index 028920471..97b379190 100644
--- a/Library/Contributions/brew_bash_completion.sh
+++ b/Library/Contributions/brew_bash_completion.sh
@@ -205,7 +205,14 @@ _brew_to_completion()
esac
fi
- case "$prev" in
+ # find the index of the *first* non-switch word
+ # we can use this to allow completion for multiple formula arguments
+ local cmd_index=1
+ while [[ ${COMP_WORDS[cmd_index]} == -* ]]; do
+ cmd_index=$((++cmd_index))
+ done
+
+ case "${COMP_WORDS[cmd_index]}" in
# Commands that take a formula
cat|deps|edit|fetch|home|homepage|info|install|log|missing|options|uses|versions)
local ff=$(\ls $(brew --repository)/Library/Formula 2> /dev/null | sed "s/\.rb//g")