From 29a8f98c75d1e6287536f863f911dd2e49951721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20B=C3=BCckendorf?= Date: Sat, 18 May 2019 21:20:47 +0200 Subject: [PATCH] aws-auth: Added bash-completion --- .bash_completion.d/completions/aws-auth | 10 ++++++++++ .environment.d/bash_completion.env | 1 + 2 files changed, 11 insertions(+) create mode 100755 .bash_completion.d/completions/aws-auth create mode 100644 .environment.d/bash_completion.env diff --git a/.bash_completion.d/completions/aws-auth b/.bash_completion.d/completions/aws-auth new file mode 100755 index 0000000..eba07cd --- /dev/null +++ b/.bash_completion.d/completions/aws-auth @@ -0,0 +1,10 @@ +function _aws-auth { + if [ "${#COMP_WORDS[@]}" != "2" ]; then + return + fi + local aws_profiles + aws_profiles="$(pcre2grep -O '$1' '(?>\[\s*profile )(\S+)(?>\s*\])' ~/.aws/config)" + COMPREPLY=($(compgen -W "$aws_profiles" "${COMP_WORDS[$COMP_CWORD]}" )) +} + +complete -F _aws-auth aws-auth diff --git a/.environment.d/bash_completion.env b/.environment.d/bash_completion.env new file mode 100644 index 0000000..13c9c48 --- /dev/null +++ b/.environment.d/bash_completion.env @@ -0,0 +1 @@ +BASH_COMPLETION_USER_DIR="${HOME}/.bash_completion.d"