From e1e3acc722133a50fba7aeee224244c499fbcdb2 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 24 Feb 2015 12:12:33 -0500 Subject: [PATCH 1/3] cask: check for Homebrew path for completion file --- plugins/cask/cask.plugin.zsh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/cask/cask.plugin.zsh b/plugins/cask/cask.plugin.zsh index c55862924..bc0006d9f 100644 --- a/plugins/cask/cask.plugin.zsh +++ b/plugins/cask/cask.plugin.zsh @@ -1,5 +1,21 @@ -if which cask &> /dev/null; then - source $(dirname $(which cask))/../etc/cask_completion.zsh -else - print "zsh cask plugin: cask not found" -fi +() { + if which cask &> /dev/null; then + local cask_bin cask_base f comp_files + cask_bin=$(which cask) + cask_base=${cask_bin:h:h} + # Plain cask installation location (for Cask 0.7.2 and earlier) + comp_files=( $cask_base/etc/cask_completion.zsh ) + # Mac Homebrew installs the completion in a different location + if which brew &> /dev/null; then + comp_files+=`brew --prefix`/share/zsh/site-functions/cask_completion.zsh + fi + for f in $comp_files; do + if [[ -f $f ]]; then + source $f; + break; + fi + done + else + print "zsh cask plugin: cask not found" + fi +} \ No newline at end of file From a7e60e4a9367117fa39ecf1de9ce63383878538b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 12 Feb 2016 18:55:53 +0100 Subject: [PATCH 2/3] Style fixes and shorter command lookup --- plugins/cask/cask.plugin.zsh | 43 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/plugins/cask/cask.plugin.zsh b/plugins/cask/cask.plugin.zsh index bc0006d9f..29120b306 100644 --- a/plugins/cask/cask.plugin.zsh +++ b/plugins/cask/cask.plugin.zsh @@ -1,21 +1,26 @@ () { - if which cask &> /dev/null; then - local cask_bin cask_base f comp_files - cask_bin=$(which cask) - cask_base=${cask_bin:h:h} - # Plain cask installation location (for Cask 0.7.2 and earlier) - comp_files=( $cask_base/etc/cask_completion.zsh ) - # Mac Homebrew installs the completion in a different location - if which brew &> /dev/null; then - comp_files+=`brew --prefix`/share/zsh/site-functions/cask_completion.zsh - fi - for f in $comp_files; do - if [[ -f $f ]]; then - source $f; - break; - fi - done - else - print "zsh cask plugin: cask not found" + emulate -L zsh + + if ! (( $+commands[cask] )); then + print "zsh cask plugin: cask command not found" >&2 + return fi -} \ No newline at end of file + + cask_base=${commands[cask]:h:h} + + # Plain cask installation location (for Cask 0.7.2 and earlier) + comp_files=($cask_base/etc/cask_completion.zsh) + + # Mac Homebrew installs the completion in a different location + if (( $+commands[brew] )); then + comp_files+=($(brew --prefix)/share/zsh/site-functions/cask_completion.zsh) + fi + + # Load first found file + for f in $comp_files; do + if [[ -f "$f" ]]; then + source "$f" + break + fi + done +} From cf4da1b7ac69505105e7e0b36155f1664f760d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 25 Aug 2016 18:33:15 +0200 Subject: [PATCH 3/3] Add README to cask plugin --- plugins/cask/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/cask/README.md diff --git a/plugins/cask/README.md b/plugins/cask/README.md new file mode 100644 index 000000000..6457fd858 --- /dev/null +++ b/plugins/cask/README.md @@ -0,0 +1,11 @@ +# cask plugin + +Loads `cask` completion from non-standard locations, such as if installed +via Homebrew or others. To enable it, add `cask` to your plugins array: + +```zsh +plugins=(... cask) +``` + +Make sure you have the `cask` directory in your `$PATH` before loading +Oh My Zsh, otherwise you'll get the "command not found" error.