1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-10-16 19:50:09 +00:00

feat(brew): add support for custom BREW_LOCATION

Fixes #11888

Co-authored-by: Matt Cable <github@curiousstranger.org>
This commit is contained in:
Carlo Sala 2023-09-13 10:48:16 +02:00
parent 01f5512311
commit 7e4c26860d
No known key found for this signature in database
GPG key ID: DA6FB450C1A4FE9A
2 changed files with 17 additions and 10 deletions

View file

@ -10,10 +10,12 @@ plugins=(... brew)
## Shellenv ## Shellenv
If `brew` is not found in the PATH, this plugin will attempt to find it in common If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute
locations, and execute `brew shellenv` to set the environment appropriately. `brew shellenv` to set the environment appropriately. This plugin will also export
This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience.
defined for convenience.
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.
## Aliases ## Aliases
@ -33,9 +35,9 @@ defined for convenience.
## Completion ## Completion
This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh. This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it
manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation,
brew installation, so we no longer ship it with the brew plugin; now it only has brew so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion
aliases. If you find that brew completion no longer works, make sure you have your Homebrew no longer works, make sure you have your Homebrew installation fully up to date.
installation fully up to date.

View file

@ -1,5 +1,10 @@
if (( ! $+commands[brew] )); then if (( ! $+commands[brew] )); then
if [[ -x /opt/homebrew/bin/brew ]]; then 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
BREW_LOCATION="/opt/homebrew/bin/brew" BREW_LOCATION="/opt/homebrew/bin/brew"
elif [[ -x /usr/local/bin/brew ]]; then elif [[ -x /usr/local/bin/brew ]]; then
BREW_LOCATION="/usr/local/bin/brew" BREW_LOCATION="/usr/local/bin/brew"