DEV Community

neetu-mallan
neetu-mallan

Posted on

Setting up Command auto completion for AWS CLI

Once you have installed the AWS CLI, it has the feature to auto complete the commands for you at the press of a TaB key. I am using a MAC & the commands here are pertaining to the Mac OS & the zsh shell is used.

To enable this, execute the foll. commands

  1. Check the location of aws_completer
    which aws_completer

  2. Check the shell using command echo $SHELL
    /bin/zsh

  3. Find the profile script of shell
    ls -a ~/

In my case its the zsh & this shell does not have a profile script .zshrc created by default even if you are using the shell

  1. Create the file using command:
    Touch ~/.zshrc

  2. Add the path of the aws_completer to this:

PATH="/usr/local/bin/aws_completer:${PATH}"
export PATH

Add the below command to the .zshrc file so that the command completion works every time you open the shell

autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit

  1. To enable command completion run the below command
    complete -C '/usr/local/bin/aws_completer' aws

  2. Execute the command below to reproduce the above changes in current shell
    source ~/.zshrc

Verify the command completion using the

aws i(TAB key press)

For other OS's , please refer to the below documentation by AWS
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html

Top comments (0)