I've found hints at there being command completion available for bash[1] for the Azure CLI (az
command), but I have not found any indication on how to install/enable that for zsh. Anyone know how to do that, if it is possible? I use oh-my-zsh, if that is relevant.

- 1,892
- 2
- 18
- 32
-
Is auto-complete feature possible for window `cmd` or even `powershell` ? – Rajesh Swarnkar Oct 20 '22 at 04:37
7 Answers
It is possible to have completions for az
in zsh.
Get the completions for bash from the Azure CLI git repo and store this file somewhere your zsh startup script can find it: https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion
Enable bash autocompletions in zsh if it's not enabled already:
autoload -U +X bashcompinit && bashcompinit
Enable the command completions for az:
source /path/to/az.completion
The code snippets from step 2 and 3 can be added to a shell startup file (.zshrc
or similar) to make the changes permanent.

- 7,115
- 4
- 45
- 59

- 1,892
- 2
- 18
- 32
-
3You should add both the `autoload` and `source` commands given above to your `.zshrc` file, autoload doesn't persist between sessions and must be run before the source command. Great answer, just want to clarify. – jboulter11 Apr 19 '19 at 16:50
-
1No sure why Microsoft is not putting some effort into the official support of ZSH. – Laith Leo Alobaidy Feb 05 '22 at 18:02
Installed Az CLI on macOS Monterey with Homebrew I've used this commands in my ~/.zshrc
file:
autoload -U +X bashcompinit && bashcompinit
source /opt/homebrew/etc/bash_completion.d/az
Autocompletion was deployed to another location.

- 208
- 2
- 5
If your OS has /etc/bash_completion.d/azure-cli
, then with oh-my-zsh it is as simple as:
$ ln -s /etc/bash_completion.d/azure-cli ~/.oh-my-zsh/custom/az.zsh
$ source ~/.zshrc
Alternatively you have to download it:
$ wget https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion \
-O ~/.oh-my-zsh/custom/az.zsh

- 3,879
- 3
- 23
- 17
In MacBook
- Download the Bash_completion script
- place the az bash completion script in /usr/local/etc/bash_completion.d
- Make sure az script with executable permissions .
- Update your .zshrc file as below autoload bashcompinit && bashcompinit source /usr/local/etc/bash_completion.d/az
- Restart your terminal.

- 21
- 3
-
Thanks for providing the paths for those of use who installed via Homebrew! – neuronaut Jul 07 '21 at 20:12
For bash here are the steps:
1: AzureJumpBox $ cd /etc/bash_completion.d/ AzureJumpBox $ ls apport_completion azure-cli git-prompt grub
2: AzureJumpBox $ source /etc/bash_completion.d/azure-cli
3: AzureJumpBox $ az aks You will see all the options

- 61
- 1
- 2
I landed on this page searching for Zsh az
completion tips. Based on the earlier posts, the following adds completion using Antidote for plugin management:
Add
Azure/azure-cli kind:clone path:az.completion
to your .zsh_plugins.txt
file
In your .zshrc
, before antidote load
, add
autoload -Uz compinit
compinit
autoload -U +X bashcompinit
bashcompinit

- 26
- 1