1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 00:10:08 +00:00

add brew-cask plugin

This commit is contained in:
Patrick Stadler 2014-01-03 14:32:49 +01:00
parent 357ab4912b
commit 288604ef1a

View file

@ -0,0 +1,80 @@
# Autocompletion for homebrew-cask.
#
# This script intercepts calls to the brew plugin and adds autocompletion
# for the cask subcommand.
#
# Author: https://github.com/pstadler
compdef _brew-cask brew
_brew-cask()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
':subcmd:->subcmd' \
'*::options:->options'
case $state in
(command)
__call_original_brew
cask_commands=(
'cask:manage casks'
)
_describe -t commands 'brew cask command' cask_commands ;;
(subcmd)
case "$line[1]" in
cask)
if (( CURRENT == 3 )); then
local -a subcommands
subcommands=(
"alfred:used to modify Alfred's scope to include the Caskroom"
'audit:verifies installability of casks'
'checklinks:checks for bad cask links'
'create:creates a cask of the given name and opens it in an editor'
'edit:edits the cask of the given name'
'home:opens the homepage of the cask of the given name'
'info:displays information about the cask of the given name'
'install:installs the cask of the given name'
'list:with no args, lists installed casks; given installed casks, lists installed files'
'search:searches all known casks'
'uninstall:uninstalls the cask of the given name'
)
_describe -t commands "brew cask subcommand" subcommands
fi ;;
*)
__call_original_brew ;;
esac ;;
(options)
local -a casks installed_casks
local expl
case "$line[2]" in
list|uninstall)
__brew_installed_casks
_wanted installed_casks expl 'installed casks' compadd -a installed_casks ;;
audit|edit|home|info|install)
__brew_all_casks
_wanted casks expl 'all casks' compadd -a casks ;;
esac ;;
esac
}
__brew_all_casks() {
casks=(`brew cask search`)
}
__brew_installed_casks() {
installed_casks=(`brew cask list`)
}
__call_original_brew()
{
local ret=1
_call_function ret _brew
compdef _brew-cask brew
}