# AX-ZSH: Alex' Modular ZSH Configuration
# homebrew.zprofile -- Setup Homebrew Package Manager
-# Make sure that "brew(1)" is installed
-(( $+commands[brew] )) || return
+# Look for the "brew(1) command ...
+for brew_cmd (
+ /home/linuxbrew/.linuxbrew/bin/brew
+ /opt/homebrew/bin/brew
+ /usr/local/bin/brew
+); do
+ [[ -x "$brew_cmd" ]] && break
+done
+if [[ ! -x "$brew_cmd" ]]; then
+ unset brew_cmd
+ return 1
+fi
-[[ -d "/usr/local/share/zsh-completions" ]] \
- && axzsh_fpath=(/usr/local/share/zsh-completions $axzsh_fpath)
+eval "$("$brew_cmd" 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")
+done
+unset dir brew_cmd
-[[ -r "$completion_file" && ! -r "$target_file" ]] \
- && ln -fs "$completion_file" "$target_file"
+# Set some defaults, if not set already.
+[[ -z "$HOMEBREW_AUTO_UPDATE_SECS" ]] && export HOMEBREW_AUTO_UPDATE_SECS=600
-unset completion_file target_file
+return 0