How to make auto-complete work for AWS on ZSH?

Solution 1:

OK - completions need a bit of help to get going - brew includes the definitions, but you have to prime the completions mechanism if you haven't enabled one yet.

brew install zsh-completions
autoload -Uz compinit
compinit

Press y when asked to ignore insecure directories

Then to test things out run the initialization:

autoload bashcompinit && bashcompinit
source /usr/local/bin/aws_zsh_completer.sh

I know - it says bash and you use zsh - you can type aws followed by a space and gla and tab and it should pause a bit and complete to the glacier command instead of file completion:

aws gla

Once that's set, you have to set up your .zshrc and likely fix the insecure compinit error by removing write permissions on some directories.

Solution 2:

I know this question is kinda old but there's a better answer if you're running awscli 2.1 or greater and are using oh-my-zsh. Basically, to confirm this solution run this command from your zsh shell

complete -C aws_completer aws

Then you can test to make sure the completion works by typing partial aws command like aws s3 and pressing tab.

If this works then you can add the complete -C aws_completer aws to you .zshrc startup profile. I got this from the following article: