diff options
| author | Jack Nagel | 2011-12-11 01:29:15 -0600 |
|---|---|---|
| committer | Jack Nagel | 2011-12-11 01:49:47 -0600 |
| commit | e4bed29e99a2fb7be5b2c175f5d38d1cb294ef92 (patch) | |
| tree | f104894fcd4333a9470e20f7027d21fa859164dd /Library/Contributions/brew_bash_completion.sh | |
| parent | ca7b7fb4f13ba97b35db7528b81971bc07233798 (diff) | |
| download | brew-e4bed29e99a2fb7be5b2c175f5d38d1cb294ef92.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/Contributions/brew_bash_completion.sh')
| -rw-r--r-- | Library/Contributions/brew_bash_completion.sh | 9 |
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") |
