From 14f0f2971f42952e2eb78fdc2535538e98323b2b Mon Sep 17 00:00:00 2001 From: Oleg Voronkovich Date: Thu, 15 Jun 2023 12:01:02 +0300 Subject: feat(brew): autoconfigure completions (#11152) --- plugins/brew/README.md | 2 ++ plugins/brew/brew.plugin.zsh | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'plugins/brew') diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 412daae63..4730194bc 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -33,6 +33,8 @@ defined for convenience. ## 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. + With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation, so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion no longer works, make sure you have your Homebrew diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index f6abe0875..b52664a39 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -25,6 +25,10 @@ if [[ -z "$HOMEBREW_PREFIX" ]]; then export HOMEBREW_PREFIX="$(brew --prefix)" fi +if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then + fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions") +fi + alias bcubc='brew upgrade --cask && brew cleanup' alias bcubo='brew update && brew outdated --cask' alias bcubc='brew upgrade --cask && brew cleanup' -- cgit v1.2.3-70-g09d2 From 7e4c26860d74a01cd6d91fd10fcc28fccd740ddd Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 13 Sep 2023 10:48:16 +0200 Subject: feat(brew): add support for custom `BREW_LOCATION` Fixes #11888 Co-authored-by: Matt Cable --- plugins/brew/README.md | 20 +++++++++++--------- plugins/brew/brew.plugin.zsh | 7 ++++++- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'plugins/brew') diff --git a/plugins/brew/README.md b/plugins/brew/README.md index 4730194bc..299393b28 100644 --- a/plugins/brew/README.md +++ b/plugins/brew/README.md @@ -10,10 +10,12 @@ plugins=(... brew) ## Shellenv -If `brew` is not found in the PATH, this plugin will attempt to find it in common -locations, and execute `brew shellenv` to set the environment appropriately. -This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously -defined for convenience. +If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute +`brew shellenv` to set the environment appropriately. This plugin will also export +`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously 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 @@ -33,9 +35,9 @@ defined for convenience. ## 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 -brew installation, so we no longer ship it with the brew plugin; now it only has brew -aliases. If you find that brew completion no longer works, make sure you have your Homebrew -installation fully up to date. +With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation, +so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion +no longer works, make sure you have your Homebrew installation fully up to date. diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index b52664a39..447036376 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,5 +1,10 @@ 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" elif [[ -x /usr/local/bin/brew ]]; then BREW_LOCATION="/usr/local/bin/brew" -- cgit v1.2.3-70-g09d2