summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Sala <carlosalag@protonmail.com>2023-02-23 23:00:31 +0100
committerGitHub <noreply@github.com>2023-02-23 23:00:31 +0100
commit8a008e1f51d451db21232edd6f1709e6c5ea334e (patch)
tree1b43561fbf3edecd516399067120478b0d69c5bb
parentb54ef89fab89eaa62ece588f96d8cbd7c222d854 (diff)
downloadzsh-8a008e1f51d451db21232edd6f1709e6c5ea334e.tar.gz
zsh-8a008e1f51d451db21232edd6f1709e6c5ea334e.tar.bz2
zsh-8a008e1f51d451db21232edd6f1709e6c5ea334e.zip
fix(azure): load completion properly for brew (#11499)
Closes #11497
-rw-r--r--plugins/azure/azure.plugin.zsh12
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh
index 7bb173a5c..51b54dbc1 100644
--- a/plugins/azure/azure.plugin.zsh
+++ b/plugins/azure/azure.plugin.zsh
@@ -32,12 +32,14 @@ function _az-homebrew-installed() {
(( $+commands[brew] )) || return 1
# speculatively check default brew prefix
- if [ -h /usr/local/opt/az ]; then
- _brew_prefix=/usr/local/opt/az
+ if [[ -d /usr/local ]]; then
+ _brew_prefix=/usr/local
+ elif [[ -d /opt/homebrew ]]; then
+ _brew_prefix=/opt/homebrew
else
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
- _brew_prefix=$(brew --prefix azure-cli)
+ _brew_prefix=$(brew --prefix)
fi
}
@@ -49,12 +51,12 @@ _az_zsh_completer_path="$commands[az_zsh_completer.sh]"
if [[ -z $_az_zsh_completer_path ]]; then
# Homebrew
if _az-homebrew-installed; then
- _az_zsh_completer_path=$_brew_prefix/libexec/bin/az.completion.sh
+ _az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
# Linux
else
_az_zsh_completer_path=/etc/bash_completion.d/azure-cli
fi
fi
-[[ -r $_az_zsh_completer_path ]] && source $_az_zsh_completer_path
+[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
unset _az_zsh_completer_path _brew_prefix