diff options
Diffstat (limited to 'Library/Contributions/brew_bash_completion.sh')
| -rw-r--r-- | Library/Contributions/brew_bash_completion.sh | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh index 028920471..355d6443f 100644 --- a/Library/Contributions/brew_bash_completion.sh +++ b/Library/Contributions/brew_bash_completion.sh @@ -63,11 +63,6 @@ _brew_to_completion() # handle subcommand options if [[ "$cur" == --* ]]; then case "${COMP_WORDS[1]}" in - audit) - local opts=$([[ "${COMP_WORDS[*]}" =~ "--strict" ]] || echo "--strict") - COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) - return - ;; cleanup) local opts=$([[ "${COMP_WORDS[*]}" =~ "--force" ]] || echo "--force") COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) @@ -205,9 +200,16 @@ _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) + audit|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") local af=$(\ls $(brew --repository)/Library/Aliases 2> /dev/null | sed "s/\.rb//g") COMPREPLY=( $(compgen -W "${ff} ${af}" -- ${cur}) ) |
