How to enable azure cli autocomplete in macos zsh shell

1. Install azure cli

brew update && brew install azure-cli

All dependencies will be instaled automatically.

The Homebrew formula of Azure CLI installs a completion file named az in the Homebrew-managed completions directory (default location is /usr/local/etc/bash_completion.d/). To enable completion, follow Homebrew’s instructions here:

For Zsh, add the following two lines to the bottom of your .zshrc file, then save and reload your Zsh profile:

autoload bashcompinit && bashcompinit
source $(brew --prefix)/etc/bash_completion.d/az

That’s it!