From 288604ef1a19c5808eff439acf32330fda126f93 Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Fri, 3 Jan 2014 14:32:49 +0100 Subject: [PATCH 1/3] add brew-cask plugin --- plugins/brew-cask/brew-cask.plugin.zsh | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 plugins/brew-cask/brew-cask.plugin.zsh diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh new file mode 100644 index 000000000..ef4f5208d --- /dev/null +++ b/plugins/brew-cask/brew-cask.plugin.zsh @@ -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 +} From 6a8f83bc5044f55e7386182683e853e6e7d2eebf Mon Sep 17 00:00:00 2001 From: Kevin Bongart Date: Fri, 21 Mar 2014 14:02:26 -0400 Subject: [PATCH 2/3] Add new brew cask commands --- plugins/brew-cask/brew-cask.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh index ef4f5208d..e0ee62293 100644 --- a/plugins/brew-cask/brew-cask.plugin.zsh +++ b/plugins/brew-cask/brew-cask.plugin.zsh @@ -34,14 +34,18 @@ _brew-cask() "alfred:used to modify Alfred's scope to include the Caskroom" 'audit:verifies installability of casks' 'checklinks:checks for bad cask links' + 'cleanup:cleans up cached downloads' 'create:creates a cask of the given name and opens it in an editor' + 'doctor:checks for configuration issues' 'edit:edits the cask of the given name' + 'fetch:downloads Cask resources to local cache' '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' + "update:a synonym for 'brew update'" ) _describe -t commands "brew cask subcommand" subcommands fi ;; From 9eadaf562ae403d9721ce5d9ea998769dd500cc9 Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Tue, 25 Mar 2014 16:56:09 +0100 Subject: [PATCH 3/3] brew-cask plugin: use spaces instead of tabs --- plugins/brew-cask/brew-cask.plugin.zsh | 114 ++++++++++++------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh index e0ee62293..91ce0f498 100644 --- a/plugins/brew-cask/brew-cask.plugin.zsh +++ b/plugins/brew-cask/brew-cask.plugin.zsh @@ -9,76 +9,76 @@ compdef _brew-cask brew _brew-cask() { - local curcontext="$curcontext" state line - typeset -A opt_args + local curcontext="$curcontext" state line + typeset -A opt_args - _arguments -C \ - ':command:->command' \ - ':subcmd:->subcmd' \ - '*::options:->options' + _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 ;; + 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' - 'cleanup:cleans up cached downloads' - 'create:creates a cask of the given name and opens it in an editor' - 'doctor:checks for configuration issues' - 'edit:edits the cask of the given name' - 'fetch:downloads Cask resources to local cache' - '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' - "update:a synonym for 'brew update'" - ) - _describe -t commands "brew cask subcommand" subcommands - fi ;; + (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' + 'cleanup:cleans up cached downloads' + 'create:creates a cask of the given name and opens it in an editor' + 'doctor:checks for configuration issues' + 'edit:edits the cask of the given name' + 'fetch:downloads Cask resources to local cache' + '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' + "update:a synonym for 'brew update'" + ) + _describe -t commands "brew cask subcommand" subcommands + fi ;; - *) - __call_original_brew ;; - esac ;; + *) + __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 + (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`) + casks=(`brew cask search`) } __brew_installed_casks() { - installed_casks=(`brew cask list`) + installed_casks=(`brew cask list`) } __call_original_brew() { - local ret=1 - _call_function ret _brew - compdef _brew-cask brew + local ret=1 + _call_function ret _brew + compdef _brew-cask brew }