From 684feffc355df95c804a6a32196248bacfefebe7 Mon Sep 17 00:00:00 2001 From: Jorge Luis Vargas Aguilar Date: Sun, 28 Oct 2018 05:17:41 -0700 Subject: aws: add README (#7357) --- plugins/aws/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 plugins/aws/README.md (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md new file mode 100644 index 000000000..8a45199b8 --- /dev/null +++ b/plugins/aws/README.md @@ -0,0 +1,20 @@ +# aws + +This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html) +and a few utilities to manage AWS profiles: a function to change profiles with autocompletion support +and a function to get the current AWS profile. The current AWS profile is also displayed in `RPROMPT`. + +To use it, add `aws` to the plugins array in your zshrc file. + +```zsh +plugins=(... aws) +``` + +## Plugin commands + +* `asp `: Sets `AWS_PROFILE` and `AWS_DEFAULT_PROFILE` (legacy) to ``. +It also adds it to your RPROMPT. + +* `agp`: Gets the current value of `AWS_PROFILE`. + +* `aws_profiles`: Lists the available profiles in the file referenced in `AWS_CONFIG_FILE` (default: ~/.aws/config). Used to provide completion for the `asp` function. -- cgit v1.2.3-70-g09d2 From e4946ef9f94360dd4767c2e58274cd62057822a5 Mon Sep 17 00:00:00 2001 From: "Vargas, Jorge L" Date: Sat, 27 Oct 2018 15:21:18 -0700 Subject: aws: change AWS_DEFAULT_PROFILE to AWS_PROFILE The environment variable name used to be AWS_DEFAULT_PROFILE but the CLI documentation now only mentions AWS_PROFILE. https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html It seems like the CLI was the only tool using AWS_DEFAULT_PROFILE, and all the AWS SDKs used AWS_PROFILE, so they standardized on it. https://onetechnical.wordpress.com/2016/10/07/the-curious-case-of-aws_default_profile/ Note: still left AWS_DEFAULT_PROFILE on the method to set the profile to maintain backwards compatibility. Close #7354 --- plugins/aws/aws.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 183b0f226..252c0d9c1 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -24,7 +24,7 @@ _awscli-homebrew-installed() { export AWS_HOME=~/.aws function agp { - echo $AWS_DEFAULT_PROFILE + echo $AWS_PROFILE } function asp { @@ -33,7 +33,7 @@ function asp { export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 - export RPROMPT="$rprompt" + export RPROMPT="$rprompt" } function aws_profiles { -- cgit v1.2.3-70-g09d2 From 543044efe3940b623069996cf6b2f5127635815f Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Sat, 27 Oct 2018 15:59:03 -0700 Subject: aws: use AWS_CONFIG_FILE to complete profiles Stop exporting AWS_HOME and use the standard AWS_CONFIG_FILE environment variable, with a fallback to ~/.aws/config (default location) if not defined. Close #7356 --- plugins/aws/aws.plugin.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 252c0d9c1..f78e96ce3 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -21,8 +21,6 @@ _awscli-homebrew-installed() { [ -r $_brew_prefix/libexec/bin/aws_zsh_completer.sh ] &> /dev/null } -export AWS_HOME=~/.aws - function agp { echo $AWS_PROFILE } @@ -37,7 +35,7 @@ function asp { } function aws_profiles { - reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) + reply=($(grep profile "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } compctl -K aws_profiles asp -- cgit v1.2.3-70-g09d2 From 0cc1266c17204b84255f924f099152c9e4f0383f Mon Sep 17 00:00:00 2001 From: Anton Stamenov Date: Mon, 31 Dec 2018 21:15:56 +0200 Subject: aws_porfiles regex is catching more lines than profiles, thus breaking completion (#7469) --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index f78e96ce3..af27e669a 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -35,7 +35,7 @@ function asp { } function aws_profiles { - reply=($(grep profile "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) + reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } compctl -K aws_profiles asp -- cgit v1.2.3-70-g09d2