From d2dc3bd2da531754778d1e9d7fb082715fc532f1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 12 Jul 2022 18:40:39 +0200 Subject: feat(brew): run `brew shellenv` command at plugin load (#10874) --- plugins/brew/brew.plugin.zsh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'plugins/brew/brew.plugin.zsh') diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 070a083d0..4a2322216 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,11 +1,35 @@ +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 +fi + +if [[ -z "$HOMEBREW_PREFIX" ]]; then + if [[ -z $BREW_LOCATION ]]; then + eval "$(brew shellenv)" + else + eval "$("$BREW_LOCATION" shellenv)" + fi +fi + +unset BREW_LOCATION + +alias bcubc='brew upgrade --cask && brew cleanup' +alias bcubo='brew update && brew outdated --cask' alias brewp='brew pin' alias brewsp='brew list --pinned' -alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' +alias bubo='brew update && brew outdated' alias bubu='bubo && bubc' alias buf='brew upgrade --formula' -alias bcubo='brew update && brew outdated --cask' -alias bcubc='brew upgrade --cask && brew cleanup' function brews() { local formulae="$(brew leaves | xargs brew deps --installed --for-each)" -- cgit v1.2.3-70-g09d2