diff --git a/zsh/.config/zsh/rc.d/01-env.zsh b/zsh/.config/zsh/rc.d/01-env.zsh index fe983d24..c08815ba 100755 --- a/zsh/.config/zsh/rc.d/01-env.zsh +++ b/zsh/.config/zsh/rc.d/01-env.zsh @@ -1,6 +1,7 @@ #!/usr/bin/env zsh -# emulate -L zsh -o EXTENDED_GLOB +emulate zsh +setopt EXTENDED_GLOB # # Environment variables @@ -25,14 +26,25 @@ export \ # Modifying one will also modify the other. # Note that each value in an array is expanded separately. Thus, we can use ~ # for $HOME in each $path entry. -_comp_dumpfile="$ZDOTDIR/zcompdump" typeset -gU FPATH PATH fpath path -path=( /{opt,usr/local}/homebrew/bin(N) /home/linuxbrew/.linuxbrew/bin(N) $path ) +# path=( /{opt,usr/local}/Homebrew/bin(N) /home/linuxbrew/.linuxbrew/bin(N) $path ) fpath=( ~/.config/zsh/(func|comple)tions(N) $fpath ) autoload -Uz ~/.config/zsh/functions/**/* -if (( $+commands[brew] )); then - eval "$(brew shellenv)" +if (( ! $+commands[brew] )); then + if [[ -x /opt/homebrew/bin/brew ]]; then + BREW_LOCATION="/opt/homebrew/bin/brew" + elif [[ -x /usr/local/bin/brew ]]; then + BREW_LOCATION="/usr/local/bin/brew" + elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then + BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew" + elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then + BREW_LOCATION="$HOME/.linuxbrew/bin/brew" + else + return + fi + eval "$("$BREW_LOCATION" shellenv)" + unset BREW_LOCATION path+=( ${HOMEBREW_PREFIX}/(s|)bin $path ) fpath+=( $HOMEBREW_PREFIX/share/zsh/site-functions(/N) $fpath ) fi