e1e3acc722133a50fba7aeee224244c499fbcdb2

Author
Andrew Janke <janke@pobox.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

cask: check for Homebrew path for completion file

Diff

 1diff --git a/plugins/cask/cask.plugin.zsh b/plugins/cask/cask.plugin.zsh
 2index c558629243d2274d8c380bc807f08d5f53690824..bc0006d9f20ca622595a5d1b6b34b7ffba0b9b39 100644
 3--- a/plugins/cask/cask.plugin.zsh
 4+++ b/plugins/cask/cask.plugin.zsh
 5@@ -1,5 +1,21 @@
 6-if which cask &> /dev/null; then
 7-  source $(dirname $(which cask))/../etc/cask_completion.zsh
 8-else
 9-  print "zsh cask plugin: cask not found"
10-fi
11+() {
12+  if which cask &> /dev/null; then
13+    local cask_bin cask_base f comp_files
14+    cask_bin=$(which cask)
15+    cask_base=${cask_bin:h:h}
16+    # Plain cask installation location (for Cask 0.7.2 and earlier)
17+    comp_files=( $cask_base/etc/cask_completion.zsh )
18+    # Mac Homebrew installs the completion in a different location
19+    if which brew &> /dev/null; then
20+      comp_files+=`brew --prefix`/share/zsh/site-functions/cask_completion.zsh
21+    fi
22+    for f in $comp_files; do
23+      if [[ -f $f ]]; then
24+        source $f;
25+        break;
26+      fi
27+    done
28+  else
29+    print "zsh cask plugin: cask not found"
30+  fi
31+}