Update _brew to support latest auto completion for Homebrew

Update based on latest changes from official Homebrew ZSH completion support.
This commit is contained in:
Ngoc Pham 2013-05-05 13:03:14 +07:00
commit 36d4dcf8b1

View file

@ -11,6 +11,10 @@ _brew_installed_formulae() {
installed_formulae=(`brew list`) installed_formulae=(`brew list`)
} }
_brew_outdated_formulae() {
outdated_formulae=(`brew outdated`)
}
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'cat:display formula file for a formula' 'cat:display formula file for a formula'
@ -26,20 +30,21 @@ _1st_arguments=(
'list:list files in a formula or not-installed formulae' 'list:list files in a formula or not-installed formulae'
'log:git commit log for a formula' 'log:git commit log for a formula'
'missing:check all installed formuale for missing dependencies.' 'missing:check all installed formuale for missing dependencies.'
'outdated:list formulas for which a newer version is available' 'outdated:list formulae for which a newer version is available'
'pin:pin specified formulae'
'prune:remove dead links' 'prune:remove dead links'
'remove:remove a formula' 'remove:remove a formula'
'search:search for a formula (/regex/ or string)' 'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)' 'server:start a local web app that lets you browse formulae (requires Sinatra)'
'unlink:unlink a formula' 'unlink:unlink a formula'
'unpin:unpin specified formulae'
'update:freshen up links' 'update:freshen up links'
'upgrade:upgrade outdated formulae' 'upgrade:upgrade outdated formulae'
'uses:show formulas which depend on a formula' 'uses:show formulae which depend on a formula'
'versions:show all available formula versions'
) )
local expl local expl
local -a formulae installed_formulae local -a formulae installed_formulae outdated_formulae
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
@ -65,6 +70,7 @@ case "$words[1]" in
list|ls) list|ls)
_arguments \ _arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'(--pinned)--pinned[list all versions of pinned formulae]' \
'(--versions)--versions[list all installed versions of a formula]' \ '(--versions)--versions[list all installed versions of a formula]' \
'1: :->forms' && return 0 '1: :->forms' && return 0
@ -72,10 +78,13 @@ case "$words[1]" in
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;; fi ;;
install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions) install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
_brew_all_formulae _brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;; _wanted formulae expl 'all formulae' compadd -a formulae ;;
remove|rm|uninstall|unlink|cleanup|link|ln) remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin)
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
upgrade)
_brew_outdated_formulae
_wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;;
esac esac