fix(brew): add sbin to PATH (#13780)

This commit is contained in:
Ininsico
2026-06-01 13:55:38 +05:00
committed by GitHub
parent cfdc4822d4
commit b86a99da17
2 changed files with 16 additions and 0 deletions

View File

@@ -17,6 +17,12 @@ If `brew` is not found in the PATH, this plugin will attempt to find it in commo
In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to
the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment. the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment.
### sbin directory
This plugin also adds `$HOMEBREW_PREFIX/sbin` to the PATH if the directory exists and isn't already present.
Some Homebrew formulae (e.g. `mtr`) install executables to `sbin`, which `brew doctor` checks for. This
ensures the `bdr` alias runs without warnings.
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |

View File

@@ -30,6 +30,16 @@ if [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX="$(brew --prefix)" export HOMEBREW_PREFIX="$(brew --prefix)"
fi fi
# Add Homebrew sbin to PATH if it exists and is not already in PATH.
# Homebrew's shellenv only adds bin directories, not sbin. Some formulae
# (e.g. mtr) install executables to sbin, and brew doctor warns if it's
# missing from PATH.
if [[ -d "$HOMEBREW_PREFIX/sbin" ]]; then
if [[ ! "$PATH" == *"$HOMEBREW_PREFIX/sbin"* ]]; then
export PATH="$HOMEBREW_PREFIX/sbin:$PATH"
fi
fi
if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions") fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
fi fi