Diff
1diff --git a/plugins/brew/README.md b/plugins/brew/README.md
2index 4730194bc681fcf7c501b5312cc2eec15f4718d1..299393b2862c870d8354c6ee6706abc2d37e9b5e 100644
3--- a/plugins/brew/README.md
4+++ b/plugins/brew/README.md
5@@ -10,10 +10,12 @@ plugins=(... brew)
6
7 ## Shellenv
8
9-If `brew` is not found in the PATH, this plugin will attempt to find it in common
10-locations, and execute `brew shellenv` to set the environment appropriately.
11-This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously
12-defined for convenience.
13+If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute
14+`brew shellenv` to set the environment appropriately. This plugin will also export
15+`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience.
16+
17+In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to
18+the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment.
19
20 ## Aliases
21
22@@ -33,9 +35,9 @@ defined for convenience.
23
24 ## Completion
25
26-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.
27+This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it
28+manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
29
30-With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
31-brew installation, so we no longer ship it with the brew plugin; now it only has brew
32-aliases. If you find that brew completion no longer works, make sure you have your Homebrew
33-installation fully up to date.
34+With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation,
35+so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion
36+no longer works, make sure you have your Homebrew installation fully up to date.
37diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
38index b52664a3900cad17024adb4f818daad267872872..44703637612cfda6bfce9046f265acda36540656 100644
39--- a/plugins/brew/brew.plugin.zsh
40+++ b/plugins/brew/brew.plugin.zsh
41@@ -1,5 +1,10 @@
42 if (( ! $+commands[brew] )); then
43- if [[ -x /opt/homebrew/bin/brew ]]; then
44+ if [[ -n "$BREW_LOCATION" ]]; then
45+ if [[ ! -x "$BREW_LOCATION" ]]; then
46+ echo "[oh-my-zsh] $BREW_LOCATION is not executable"
47+ return
48+ fi
49+ elif [[ -x /opt/homebrew/bin/brew ]]; then
50 BREW_LOCATION="/opt/homebrew/bin/brew"
51 elif [[ -x /usr/local/bin/brew ]]; then
52 BREW_LOCATION="/usr/local/bin/brew"