bash completion: --options for brew install foo

To trigger the option autocompletion, type:

    brew install foo --[tab][tab]

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
Justin Hileman 2011-02-04 18:21:23 -05:00 committed by Adam Vandenberg
parent 9752fc93fd
commit 97b8f9a31f

View File

@ -39,6 +39,13 @@ _brew_to_completion()
COMPREPLY=( $(compgen -W "$(\ls $(brew --cellar))" -- ${cur}) ) COMPREPLY=( $(compgen -W "$(\ls $(brew --cellar))" -- ${cur}) )
return return
;; ;;
# Complete --options for selected brew
*)
[[ ${COMP_WORDS[1]} == "install" ]] && [[ "$cur" == --* ]] && {
COMPREPLY=( $(compgen -W "$(brew options "$prev" | grep -P "^--")" -- ${cur}) )
return
}
;;
esac esac
} }