Shell completion lets AWS CLI suggest matching services, operations, and flags while a command is still being typed. That shortens repetitive help lookups and makes long command lines less error-prone.
The feature is provided by aws_completer. On AWS CLI v2, the same completion engine can also suggest some resource values after parameters such as --table-name when the active profile and region can query them.
On Linux and macOS, completion is enabled by loading the right rule from the startup file for the shell that actually runs aws. PowerShell on Windows uses a different profile-registration flow, and Amazon Linux on EC2 often enables completion already, so the main job here is to register aws_completer in the current shell profile without guessing the path.
Related: How to configure AWS CLI on Linux and macOS
Related: How to check AWS CLI version
Steps to enable AWS CLI shell completion:
- Confirm that the current shell can find aws_completer.
$ which aws_completer /usr/local/bin/aws_completer
If no path is returned, fix the AWS CLI install or PATH first. Common locations include /usr/local/bin, /opt/homebrew/bin, and ~/.local/bin.
Related: How to install AWS CLI on Ubuntu
Related: How to install AWS CLI on CentOS Stream or Red Hat Enterprise Linux
Related: How to install AWS CLI version 1 using pip - Identify the shell whose startup file should load the completion rule.
$ echo $SHELL /bin/zsh
Use ~/.bashrc for bash, ~/.zshrc for zsh, and ~/.tcshrc for tcsh. If the terminal launches a different shell after login, run the check inside that shell before editing anything.
- Add the bash completion rule to ~/.bashrc when the shell is bash.
complete -C '/usr/local/bin/aws_completer' aws
Keep the absolute path returned by which aws_completer if it differs from the example. Login shells should still source ~/.bashrc from ~/.bash_profile, ~/.profile, or ~/.bash_login so the rule is active in new terminal sessions.
- Add the zsh completion lines to ~/.zshrc when the shell is zsh.
autoload bashcompinit && bashcompinit autoload -Uz compinit && compinit complete -C '/usr/local/bin/aws_completer' aws
If ~/.zshrc already initializes compinit, keep that existing line and add the missing bashcompinit or complete -C lines after it instead of creating duplicate startup blocks.
- Add the tcsh completion rule to ~/.tcshrc when the shell is tcsh.
complete aws 'p/*/`aws_completer`/'
If aws_completer is not already in the shell PATH, replace it inside the backticks with the absolute path returned by which aws_completer.
- Reload the startup file that you changed.
$ source ~/.zshrc
Use source ~/.bashrc or source ~/.tcshrc instead when those are the files you updated. Opening a new terminal window has the same effect.
- Enter a partial AWS CLI command and press Tab twice to confirm that completion now lists matching operations.
$ aws sts g<Tab><Tab> get-access-key-info get-federation-token get-caller-identity get-session-token get-delegated-access-token get-web-identity-token
AWS CLI v2 can also suggest some live resource values after parameters such as --table-name when the active credentials can list them in the current region.
Related: How to check AWS CLI version
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
