8a008e1f51d451db21232edd6f1709e6c5ea334e
- Author
- Carlo Sala <carlosalag@protonmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(azure): load completion properly for brew (#11499)
Closes #11497
Diff
1diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh
2index 7bb173a5c1e0c127f5a20813c2dda47fa4f1d3c1..51b54dbc11b04032d0b442e4786f3e55e697b72e 100644
3--- a/plugins/azure/azure.plugin.zsh
4+++ b/plugins/azure/azure.plugin.zsh
5@@ -32,12 +32,14 @@ function _az-homebrew-installed() {
6 (( $+commands[brew] )) || return 1
7
8 # speculatively check default brew prefix
9- if [ -h /usr/local/opt/az ]; then
10- _brew_prefix=/usr/local/opt/az
11+ if [[ -d /usr/local ]]; then
12+ _brew_prefix=/usr/local
13+ elif [[ -d /opt/homebrew ]]; then
14+ _brew_prefix=/opt/homebrew
15 else
16 # ok, it is not in the default prefix
17 # this call to brew is expensive (about 400 ms), so at least let's make it only once
18- _brew_prefix=$(brew --prefix azure-cli)
19+ _brew_prefix=$(brew --prefix)
20 fi
21 }
22
23@@ -49,12 +51,12 @@ _az_zsh_completer_path="$commands[az_zsh_completer.sh]"
24 if [[ -z $_az_zsh_completer_path ]]; then
25 # Homebrew
26 if _az-homebrew-installed; then
27- _az_zsh_completer_path=$_brew_prefix/libexec/bin/az.completion.sh
28+ _az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
29 # Linux
30 else
31 _az_zsh_completer_path=/etc/bash_completion.d/azure-cli
32 fi
33 fi
34
35-[[ -r $_az_zsh_completer_path ]] && source $_az_zsh_completer_path
36+[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
37 unset _az_zsh_completer_path _brew_prefix