From ed87310ea71024f25bfc0c0066fed2002396136c Mon Sep 17 00:00:00 2001 From: Jahir Vidrio Date: Thu, 30 Apr 2026 23:48:32 -0600 Subject: [PATCH] feat(brew): :sparkles: Add option to disable aliases Allow users to opt-out of default aliases by setting `zstyle :omz:plugins:brew aliases no`. Aliases remain enabled by default to maintain backward compatibility. --- plugins/brew/README.md | 13 +++++ plugins/brew/brew.plugin.zsh | 94 ++++++++++++++++++------------------ 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/plugins/brew/README.md b/plugins/brew/README.md index ab0b9cd73..f8a505d41 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -8,6 +8,19 @@ To use it, add `brew` to the plugins array of your zshrc file: plugins=(... brew) ``` +## Settings + +### Aliases + +If you don't want to use the aliases provided by this plugin, you can disable them by setting the following style +in your `.zshrc` file, before Oh My Zsh is sourced: + +```zsh +zstyle ':omz:plugins:brew' aliases no +``` + +Default: `yes`. + ## Shellenv If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 7d5db2068..77694b2ce 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -34,52 +34,54 @@ if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions") fi -alias ba='brew autoremove' -alias bcfg='brew config' -alias bci='brew info --cask' -alias bcin='brew install --cask' -alias bcl='brew list --cask' -alias bcn='brew cleanup' -alias bco='brew outdated --cask' -alias bcrin='brew reinstall --cask' -alias bcubc='brew upgrade --cask && brew cleanup' -alias bcubo='brew update && brew outdated --cask' -alias bcup='brew upgrade --cask' -alias bdr='brew doctor' -alias bfu='brew upgrade --formula' -alias bi='brew install' -alias bih='brew install --HEAD' -alias bl='brew list' -alias bo='brew outdated' -alias br='brew reinstall' -alias brewp='brew pin' -alias brewsp='brew list --pinned' -alias brh='brew reinstall --HEAD' -alias bs='brew search' -alias bsl='brew services list' -alias bsoff='brew services stop' -alias bsoffa='bsoff --all' -alias bson='brew services start' -alias bsona='bson --all' -alias bsr='brew services run' -alias bsra='bsr --all' -alias bu='brew update' -alias bubo='brew update && brew outdated' -alias bubu='bubo && bup' -alias bubug='bubo && bugbc' -alias bugbc='brew upgrade --greedy && brew cleanup' -alias bup='brew upgrade' -alias buz='brew uninstall --zap' +if zstyle -T ':omz:plugins:brew' aliases; then + alias ba='brew autoremove' + alias bcfg='brew config' + alias bci='brew info --cask' + alias bcin='brew install --cask' + alias bcl='brew list --cask' + alias bcn='brew cleanup' + alias bco='brew outdated --cask' + alias bcrin='brew reinstall --cask' + alias bcubc='brew upgrade --cask && brew cleanup' + alias bcubo='brew update && brew outdated --cask' + alias bcup='brew upgrade --cask' + alias bdr='brew doctor' + alias bfu='brew upgrade --formula' + alias bi='brew install' + alias bih='brew install --HEAD' + alias bl='brew list' + alias bo='brew outdated' + alias br='brew reinstall' + alias brewp='brew pin' + alias brewsp='brew list --pinned' + alias brh='brew reinstall --HEAD' + alias bs='brew search' + alias bsl='brew services list' + alias bsoff='brew services stop' + alias bsoffa='bsoff --all' + alias bson='brew services start' + alias bsona='bson --all' + alias bsr='brew services run' + alias bsra='bsr --all' + alias bu='brew update' + alias bubo='brew update && brew outdated' + alias bubu='bubo && bup' + alias bubug='bubo && bugbc' + alias bugbc='brew upgrade --greedy && brew cleanup' + alias bup='brew upgrade' + alias buz='brew uninstall --zap' -function brews() { - local formulae="$(brew leaves | xargs brew deps --installed --for-each)" - local casks="$(brew list --cask 2>/dev/null)" + function brews() { + local formulae="$(brew leaves | xargs brew deps --installed --for-each)" + local casks="$(brew list --cask 2>/dev/null)" - local blue="$(tput setaf 4)" - local bold="$(tput bold)" - local off="$(tput sgr0)" + 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}" -} + echo "${blue}==>${off} ${bold}Formulae${off}" + echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/" + echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}" + } +fi