diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2022-11-05 14:55:11 -0700 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2022-11-05 14:55:11 -0700 |
commit | 04b8c052e5b624873b352889423c753ed1baf9c4 (patch) | |
tree | 78e14fe69e61d69709f31f91b7ae29fe8bc74477 /plugins/brew | |
parent | 1a6dcd017dbf564058a729032de3db139fcf9c7e (diff) | |
parent | 80fdbc9b91a9acca42fb90065b5e64a9722978a7 (diff) | |
download | zsh-04b8c052e5b624873b352889423c753ed1baf9c4.tar.gz zsh-04b8c052e5b624873b352889423c753ed1baf9c4.tar.bz2 zsh-04b8c052e5b624873b352889423c753ed1baf9c4.zip |
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'plugins/brew')
-rw-r--r-- | plugins/brew/README.md | 5 | ||||
-rw-r--r-- | plugins/brew/brew.plugin.zsh | 19 |
2 files changed, 15 insertions, 9 deletions
diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 64e0e1153..9ce2c5bb0 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -10,7 +10,10 @@ plugins=(... brew) ## Shellenv -This plugin also executes `brew shellenv` at plugin load to set up many useful variables, such as `HOMEBREW_PREFIX` or `HOMEBREW_REPOSITORY`. +If `brew` is not found in the PATH, this plugin will attempt to find it in common +locations, and execute `brew shellenv` to set the environment appropriately. +This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously +defined for convenience. ## Aliases diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 4a2322216..ea8900823 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -10,18 +10,21 @@ if (( ! $+commands[brew] )); then else return fi + + # Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is + # not already on the path, to prevent duplicate entries. This aligns with + # the behavior of the brew installer.sh post-install steps. + eval "$("$BREW_LOCATION" shellenv)" + unset BREW_LOCATION fi if [[ -z "$HOMEBREW_PREFIX" ]]; then - if [[ -z $BREW_LOCATION ]]; then - eval "$(brew shellenv)" - else - eval "$("$BREW_LOCATION" shellenv)" - fi + # Maintain compatability with potential custom user profiles, where we had + # previously relied on always sourcing shellenv. OMZ plugins should not rely + # on this to be defined due to out of order processing. + export HOMEBREW_PREFIX="$(brew --prefix)" fi -unset BREW_LOCATION - alias bcubc='brew upgrade --cask && brew cleanup' alias bcubo='brew update && brew outdated --cask' alias brewp='brew pin' @@ -33,7 +36,7 @@ alias buf='brew upgrade --formula' function brews() { local formulae="$(brew leaves | xargs brew deps --installed --for-each)" - local casks="$(brew list --cask)" + local casks="$(brew list --cask 2>/dev/null)" local blue="$(tput setaf 4)" local bold="$(tput bold)" |