2022-07-13 00:40:39 +08:00
|
|
|
if (( ! $+commands[brew] )); then
|
2023-09-13 16:48:16 +08:00
|
|
|
if [[ -n "$BREW_LOCATION" ]]; then
|
|
|
|
if [[ ! -x "$BREW_LOCATION" ]]; then
|
|
|
|
echo "[oh-my-zsh] $BREW_LOCATION is not executable"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
elif [[ -x /opt/homebrew/bin/brew ]]; then
|
2022-07-13 00:40:39 +08:00
|
|
|
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
|
2022-10-15 02:27:42 +08:00
|
|
|
|
|
|
|
# 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
|
2022-07-13 00:40:39 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$HOMEBREW_PREFIX" ]]; then
|
2022-10-15 02:27:42 +08:00
|
|
|
# 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)"
|
2022-07-13 00:40:39 +08:00
|
|
|
fi
|
|
|
|
|
2023-06-15 17:01:02 +08:00
|
|
|
if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
|
|
|
|
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
|
|
|
|
fi
|
|
|
|
|
2022-07-13 00:40:39 +08:00
|
|
|
alias bcubc='brew upgrade --cask && brew cleanup'
|
|
|
|
alias bcubo='brew update && brew outdated --cask'
|
2018-08-30 02:53:24 +08:00
|
|
|
alias brewp='brew pin'
|
|
|
|
alias brewsp='brew list --pinned'
|
2015-06-01 01:34:01 +08:00
|
|
|
alias bubc='brew upgrade && brew cleanup'
|
2023-01-10 03:07:41 +08:00
|
|
|
alias bugbc='brew upgrade --greedy && brew cleanup'
|
2022-07-13 00:40:39 +08:00
|
|
|
alias bubo='brew update && brew outdated'
|
2015-06-01 01:34:01 +08:00
|
|
|
alias bubu='bubo && bubc'
|
2023-01-10 03:07:41 +08:00
|
|
|
alias bubug='bubo && bugbc'
|
2023-01-19 19:20:44 +08:00
|
|
|
alias bfu='brew upgrade --formula'
|
2023-01-10 03:02:44 +08:00
|
|
|
alias buz='brew uninstall --zap'
|
2021-12-18 08:15:39 +08:00
|
|
|
|
|
|
|
function brews() {
|
|
|
|
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
|
2022-11-04 01:32:01 +08:00
|
|
|
local casks="$(brew list --cask 2>/dev/null)"
|
2021-12-18 08:15:39 +08:00
|
|
|
|
|
|
|
local blue="$(tput setaf 4)"
|
|
|
|
local bold="$(tput bold)"
|
|
|
|
local off="$(tput sgr0)"
|
|
|
|
|
|
|
|
echo "${blue}==>${off} ${bold}Formulae${off}"
|
|
|
|
echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
|
|
|
|
echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
|
|
|
|
}
|