-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add aliases to tab completion #26
Comments
Any updates on this request? |
Aliases would require manual shell completion files. It's possible to create your own completion files but not something that is supported by |
So to add AWS CLI aliases to bash completions for _aws_cli_aliases()
{
COMPREPLY=()
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
local cword=${COMP_WORDS[0]}
if [[ $cur =~ ^- ]]; then
if [[ $(aws version 2>&1 | awk -F"[/ .]" '{print $2}') -gt 1 ]]; then
local all_global_opts=$(~/bin/aws-list-all-available-commands.py global_opts)
COMPREPLY=($(compgen -W "$all_global_opts" -- $cur))
else
return 0
fi
elif [[ $prev == --profile ]]; then
COMPREPLY=($(compgen -W "$(awk '/^\[/' ${AWS_SHARED_CREDENTIALS_FILE:=${HOME}/.aws/credentials} | tr -d '[]' | sort)" $cur))
elif [[ $prev == --region ]]; then
# aws ec2 describe-regions --query 'Regions[].RegionName[]' --output text | xargs -n1
COMPREPLY=($(compgen -W "eu-north-1 ap-south-1 eu-west-3 eu-west-2 eu-west-1 ap-northeast-2 ap-northeast-1 sa-east-1 ca-central-1 ap-southeast-1 ap-southeast-2 eu-central-1 us-east-1 us-east-2 us-west-1 us-west-2" $cur))
elif [[ $prev == --output ]]; then
COMPREPLY=($(compgen -W "json yaml yaml-stream text table" $cur))
else
local cmds_hits
local all_cmds=$(~/bin/aws-list-all-available-commands.py)
local all_aliases=$(awk '$2 == "=" && $1 !~ /^#/ {print $1}' ~/.aws/cli/alias | sort)
for cli_alias in $all_aliases; do
if [[ $prev == $cli_alias ]]; then
local all_global_opts=$(~/bin/aws-list-all-available-commands.py global_opts)
COMPREPLY=($(compgen -W "$all_global_opts" -- $cur))
return 0
fi
done
for cli_cmd in ${COMP_WORDS[@]}; do
for aws_cmd in $all_cmds $all_aliases; do
if [[ $aws_cmd == $cli_cmd ]]; then
((cmds_hits++))
break 2
fi
done
done
[[ ! $cmds_hits ]] && COMPREPLY=($(compgen -W "$all_aliases" $cur))
fi
return 0
}
complete -C aws_completer -F _aws_cli_aliases aws
Hope this helps someone... |
I've been a bit frustrated that I can't tab complete my aliases.
This test seems to indicate that it is by design, but why? https://github.com/aws/aws-cli/blob/3db7be30dfdd76f4e322b83b67af3134ae0b32ac/tests/functional/docs/test_help_output.py#L457
The text was updated successfully, but these errors were encountered: