]> arthur.barton.de Git - ax-zsh.git/blobdiff - plugins/homebrew/homebrew.zprofile
homebrew: Fix detection of Homebrew command completions
[ax-zsh.git] / plugins / homebrew / homebrew.zprofile
index 476b65dd3790fdbfcb7a1af210768d487f070257..84cb740d0347bfcc6f29dafe79eae2d680b2d814 100644 (file)
@@ -2,15 +2,17 @@
 # homebrew.zprofile -- Setup Homebrew Package Manager
 
 # Make sure that "brew(1)" is installed
-(( $+commands[brew] )) || return
+(( $+commands[brew] )) || return 1
 
-[[ -d "/usr/local/share/zsh-completions" ]] \
-       && axzsh_fpath=(/usr/local/share/zsh-completions $axzsh_fpath)
+eval "$(brew shellenv)"
 
-completion_file="$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh"
-target_file="$(dirname "$0")/functions/_brew"
+for dir (
+       "$HOMEBREW_PREFIX/share/zsh-completions"
+       "$HOMEBREW_PREFIX/share/zsh/site-functions"
+); do
+       [[ -d "$dir" ]] && axzsh_fpath+=("$dir")
 
-[[ -r "$completion_file" && ! -r "$target_file" ]] \
-       && ln -fs "$completion_file" "$target_file"
+done
+unset dir
 
-unset completion_file target_file
+return 0