From 9d6b6c5ce161280e52df3a33d584318d6dbc0bd9 Mon Sep 17 00:00:00 2001 From: T0mK0 Date: Tue, 7 Nov 2017 11:03:54 -0500 Subject: speed up chruby plugin by eliminating(as much as possible) calls to brew (#6080) * speed up chruby plugin by eliminating(as much as possible) calls to brew * speed up aws plugin by eliminating(as much as possible) calls to brew --- plugins/aws/aws.plugin.zsh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d31052f83..6a0e04add 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,9 +1,24 @@ _homebrew-installed() { type brew &> /dev/null + _xit=$? + if [ $_xit -eq 0 ];then + # ok , we have brew installed + # speculatively we check default brew prefix + if [ -h /usr/local/opt/awscli ];then + _brew_prefix="/usr/local/opt/awscli" + else + # ok , it is not default prefix + # this call to brew is expensive ( about 400 ms ), so at least let's make it only once + _brew_prefix=$(brew --prefix awscli) + fi + return 0 + else + return $_xit + fi } _awscli-homebrew-installed() { - brew list awscli &> /dev/null + [ -r $_brew_prefix/libexec/bin/aws_zsh_completer.sh ] &> /dev/null } export AWS_HOME=~/.aws @@ -28,7 +43,7 @@ function aws_profiles { compctl -K aws_profiles asp if _homebrew-installed && _awscli-homebrew-installed ; then - _aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh + _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh else _aws_zsh_completer_path=$(which aws_zsh_completer.sh) fi -- cgit v1.2.3-70-g09d2 From e8c328cb394e39f8d1c7d18b85b0be12bd71c556 Mon Sep 17 00:00:00 2001 From: Hosh Date: Thu, 10 May 2018 19:53:16 +0100 Subject: Update AWS completion (#6745) --- plugins/aws/aws.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 6a0e04add..a326e2e01 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -42,11 +42,11 @@ function aws_profiles { compctl -K aws_profiles asp -if _homebrew-installed && _awscli-homebrew-installed ; then +if which aws_zsh_completer.sh &>/dev/null; then + _aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null) +elif _homebrew-installed && _awscli-homebrew-installed; then _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=$(which aws_zsh_completer.sh) fi -[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path +[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path unset _aws_zsh_completer_path -- cgit v1.2.3-70-g09d2 From e8aaab56b9f007cd5a285099fa101a63214622ee Mon Sep 17 00:00:00 2001 From: Frank Wittig Date: Wed, 9 Apr 2014 18:11:06 +0200 Subject: allow . in profile names --- plugins/aws/aws.plugin.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index a326e2e01..183b0f226 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -37,9 +37,8 @@ function asp { } function aws_profiles { - reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) + reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } - compctl -K aws_profiles asp if which aws_zsh_completer.sh &>/dev/null; then -- cgit v1.2.3-70-g09d2 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 From 1a2d930bca7966c44f1551ea2f0b8d7aecc80e56 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 23 Mar 2019 19:52:31 +0100 Subject: aws: refactor completion sourcing logic (#7364) * Clean up Homebrew detection and add comments. Also changed some if flags. * Detect aws cli completion file from RPM --- plugins/aws/aws.plugin.zsh | 56 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index af27e669a..9cb69dd09 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,32 +1,9 @@ -_homebrew-installed() { - type brew &> /dev/null - _xit=$? - if [ $_xit -eq 0 ];then - # ok , we have brew installed - # speculatively we check default brew prefix - if [ -h /usr/local/opt/awscli ];then - _brew_prefix="/usr/local/opt/awscli" - else - # ok , it is not default prefix - # this call to brew is expensive ( about 400 ms ), so at least let's make it only once - _brew_prefix=$(brew --prefix awscli) - fi - return 0 - else - return $_xit - fi -} - -_awscli-homebrew-installed() { - [ -r $_brew_prefix/libexec/bin/aws_zsh_completer.sh ] &> /dev/null -} - function agp { echo $AWS_PROFILE } function asp { - local rprompt=${RPROMPT//} + local rprompt=${RPROMPT//} export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 @@ -39,11 +16,32 @@ function aws_profiles { } compctl -K aws_profiles asp -if which aws_zsh_completer.sh &>/dev/null; then - _aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null) -elif _homebrew-installed && _awscli-homebrew-installed; then + +# Load awscli completions + +_awscli-homebrew-installed() { + # check if Homebrew is installed + (( $+commands[brew] )) || return 1 + + # speculatively check default brew prefix + if [ -h /usr/local/opt/awscli ]; then + _brew_prefix=/usr/local/opt/awscli + else + # ok, it is not in the default prefix + # this call to brew is expensive (about 400 ms), so at least let's make it only once + _brew_prefix=$(brew --prefix awscli) + fi +} + +# get aws_zsh_completer.sh location from $PATH +_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" + +# otherwise check if installed via Homebrew +if [[ -z $_aws_zsh_completer_path ]] && _awscli-homebrew-installed; then _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh +else + _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh fi -[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path -unset _aws_zsh_completer_path +[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path +unset _aws_zsh_completer_path _brew_prefix -- cgit v1.2.3-70-g09d2 From 532a784b806375370022605d8be17c1116553572 Mon Sep 17 00:00:00 2001 From: David Kane Date: Sun, 24 Mar 2019 18:37:07 +0000 Subject: aws: refactor AWS plugin (#7615) * Update the AWS plugin to support disabling RPROMT display: Use a $SHOW_AWS_PROMPT option. * Refactoring aws plugin: Exposing customizable aws_prompt_info function to be used in themes. * Set aws prompt prefix and suffix to original values and fix README Co-authored-by: "Vassilis S. Moustakas" --- plugins/aws/README.md | 25 +++++++++++++++++++------ plugins/aws/aws.plugin.zsh | 20 +++++++++++++++++--- 2 files changed, 36 insertions(+), 9 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 8a45199b8..57ab1e5ac 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -1,8 +1,7 @@ # 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`. +and a few utilities to manage AWS profiles and display them in the prompt. To use it, add `aws` to the plugins array in your zshrc file. @@ -12,9 +11,23 @@ plugins=(... aws) ## Plugin commands -* `asp `: Sets `AWS_PROFILE` and `AWS_DEFAULT_PROFILE` (legacy) to ``. -It also adds it to your RPROMPT. +* `asp []`: Sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. + Run `asp` without arguments to clear the profile. -* `agp`: Gets the current value of `AWS_PROFILE`. +* `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. +* `aws_profiles`: Lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`). + Used to provide completion for the `asp` function. + +## Plugin options + +* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. + +## Theme + +The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays +the current `$AWS_PROFILE`. It uses two variables to control how that is shown: + +- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to ``. diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 9cb69dd09..2fb351812 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,14 +1,16 @@ +# AWS profile selection + function agp { echo $AWS_PROFILE } function asp { - local rprompt=${RPROMPT//} - export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 - export RPROMPT="$rprompt" + if [[ -z "$1" ]]; then + echo AWS profile cleared. + fi } function aws_profiles { @@ -17,6 +19,18 @@ function aws_profiles { compctl -K aws_profiles asp +# AWS prompt + +function aws_prompt_info() { + [[ -z $AWS_PROFILE ]] && return + echo "${ZSH_THEME_AWS_PREFIX:=}" +} + +if [ "$SHOW_AWS_PROMPT" != false ]; then + export RPROMPT='$(aws_prompt_info)'"$RPROMPT" +fi + + # Load awscli completions _awscli-homebrew-installed() { -- cgit v1.2.3-70-g09d2 From 8cbdd79517d710e5bab6ce7aca0754b37462f2ee Mon Sep 17 00:00:00 2001 From: Logan Lindquist Date: Sun, 24 Mar 2019 13:46:27 -0500 Subject: aws: set AWS_EB_PROFILE for the EB CLI (#7388) Added AWS_EB_PROFILE environment variable to the AWS Plugin. The EB CLI uses this variable instead of the primary AWS_PROFILE variable to keep track of what profile it is using. https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html --- plugins/aws/README.md | 1 + plugins/aws/aws.plugin.zsh | 1 + 2 files changed, 2 insertions(+) (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 57ab1e5ac..45e6de937 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -12,6 +12,7 @@ plugins=(... aws) ## Plugin commands * `asp []`: Sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. + It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. Run `asp` without arguments to clear the profile. * `agp`: Gets the current value of `$AWS_PROFILE`. diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 2fb351812..944557e14 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -7,6 +7,7 @@ function agp { function asp { export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 + export AWS_EB_PROFILE=$1 if [[ -z "$1" ]]; then echo AWS profile cleared. -- cgit v1.2.3-70-g09d2 From 4f4985fddc632a1d9745aec94ce95bea10006f97 Mon Sep 17 00:00:00 2001 From: Cristian Măgherușan-Stanciu Date: Wed, 30 Jul 2014 14:59:00 +0200 Subject: aws: added an alias for changing the AWS access key set on a profile --- plugins/aws/aws.plugin.zsh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 944557e14..7005af2d6 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -14,10 +14,25 @@ function asp { fi } +function aws_change_access_key { + if [[ "x$1" == "x" ]] then + echo "usage: $0 " + return 1 + else + echo "Insert the credentials when asked." + asp $1 + aws iam create-access-key + aws configure --profile $1 + echo "You can now safely delete the old access key running 'aws iam delete-access-key --access-key-id ID'" + echo "Your current keys are:" + aws iam list-access-keys + fi +} + function aws_profiles { reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } -compctl -K aws_profiles asp +compctl -K aws_profiles asp aws_change_access_key # AWS prompt -- cgit v1.2.3-70-g09d2 From 5f893dcd209fdad920a1450355acbd4c10faabf2 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 23 Mar 2019 20:56:55 +0100 Subject: aws: clean up aws_change_access_key function --- plugins/aws/aws.plugin.zsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 7005af2d6..6de329bb8 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -15,18 +15,19 @@ function asp { } function aws_change_access_key { - if [[ "x$1" == "x" ]] then - echo "usage: $0 " + if [[ -z "$1" ]] then + echo "usage: $0 " return 1 - else - echo "Insert the credentials when asked." - asp $1 - aws iam create-access-key - aws configure --profile $1 - echo "You can now safely delete the old access key running 'aws iam delete-access-key --access-key-id ID'" - echo "Your current keys are:" - aws iam list-access-keys fi + + echo Insert the credentials when asked. + asp "$1" + aws iam create-access-key + aws configure --profile "$1" + + echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\` + echo Your current keys are: + aws iam list-access-keys } function aws_profiles { -- cgit v1.2.3-70-g09d2 From 6d143d42ea2e16610855e5b1e912b2962d44d9ab Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 24 Mar 2019 19:54:56 +0100 Subject: aws: document aws_change_access_key and fix README --- plugins/aws/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 45e6de937..a52024128 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -11,13 +11,15 @@ plugins=(... aws) ## Plugin commands -* `asp []`: Sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. +* `asp []`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to ``. It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. Run `asp` without arguments to clear the profile. -* `agp`: Gets the current value of `$AWS_PROFILE`. +* `agp`: gets the current value of `$AWS_PROFILE`. -* `aws_profiles`: Lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`). +* `aws_change_access_key`: changes the AWS access key of a profile. + +* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`). Used to provide completion for the `asp` function. ## Plugin options -- cgit v1.2.3-70-g09d2 From 53d6a692d14a035d03765e72c7c9425bba1b3972 Mon Sep 17 00:00:00 2001 From: programmer04 Date: Mon, 8 Apr 2019 22:08:37 +0200 Subject: Fix showing aws prompt for theme fishy (append RPROMPT instead of overwrite) --- plugins/aws/README.md | 2 +- themes/fishy.zsh-theme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md index a52024128..d83c3fafe 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -24,7 +24,7 @@ plugins=(... aws) ## Plugin options -* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. +* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. Some plugins overwrite the value of RPROMPT instead of appending to it, so they need to be fixed to see a default aws plugin RPROMPT message (for example theme fishy is fixed). ## Theme diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index 83bd455b5..00a60f45b 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -14,7 +14,7 @@ PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) PROMPT2='%{$fg[red]%}\ %{$reset_color%}' local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}" -RPROMPT='${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}' +RPROMPT="${RPROMPT}"'${return_status}$(git_prompt_info)$(git_prompt_status)%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX=" " ZSH_THEME_GIT_PROMPT_SUFFIX="" -- cgit v1.2.3-70-g09d2 From 63291f4fcc07de3014362ef5101132d91ad3d497 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 9 Apr 2019 18:24:04 +0200 Subject: Reword and fix formatting --- plugins/aws/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins/aws') diff --git a/plugins/aws/README.md b/plugins/aws/README.md index d83c3fafe..57c3b54ac 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -24,7 +24,9 @@ plugins=(... aws) ## Plugin options -* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. Some plugins overwrite the value of RPROMPT instead of appending to it, so they need to be fixed to see a default aws plugin RPROMPT message (for example theme fishy is fixed). +* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. + Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to + see the AWS profile prompt. ## Theme -- cgit v1.2.3-70-g09d2 From 5f9cc016d7fb19004529ea935d6a386846ad46e2 Mon Sep 17 00:00:00 2001 From: programmer04 Date: Tue, 9 Apr 2019 21:07:42 +0200 Subject: Fix redundant export of RPROMPT in aws plugin --- 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 6de329bb8..0895cfb3a 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -44,7 +44,7 @@ function aws_prompt_info() { } if [ "$SHOW_AWS_PROMPT" != false ]; then - export RPROMPT='$(aws_prompt_info)'"$RPROMPT" + RPROMPT='$(aws_prompt_info)'"$RPROMPT" fi -- cgit v1.2.3-70-g09d2 From d16adb6a9f9b0ea46121f48751a012f0511b465b Mon Sep 17 00:00:00 2001 From: dorons Date: Mon, 29 Apr 2019 12:42:36 +0300 Subject: aws: fix path resolution of aws completion for Ubuntu (#7812) --- plugins/aws/aws.plugin.zsh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 0895cfb3a..4bec30490 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -67,11 +67,18 @@ _awscli-homebrew-installed() { # get aws_zsh_completer.sh location from $PATH _aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" -# otherwise check if installed via Homebrew -if [[ -z $_aws_zsh_completer_path ]] && _awscli-homebrew-installed; then - _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh +# otherwise check common locations +if [[ -z $_aws_zsh_completer_path ]]; then + # Homebrew + if _awscli-homebrew-installed; then + _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh + # Ubuntu + elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then + _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli + # RPM + else + _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh + fi fi [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path -- cgit v1.2.3-70-g09d2 From 4585c6662be4cefafd6e67df1d859abb7988168e Mon Sep 17 00:00:00 2001 From: Mohamed El Mouctar Haidara Date: Fri, 10 May 2019 17:28:31 +0200 Subject: aws: really unset AWS*PROFILE variables in asp function (#7838) --- plugins/aws/aws.plugin.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 4bec30490..d70a64fcc 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -5,13 +5,15 @@ function agp { } function asp { - export AWS_DEFAULT_PROFILE=$1 - export AWS_PROFILE=$1 - export AWS_EB_PROFILE=$1 - if [[ -z "$1" ]]; then + unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE echo AWS profile cleared. + return fi + + export AWS_DEFAULT_PROFILE=$1 + export AWS_PROFILE=$1 + export AWS_EB_PROFILE=$1 } function aws_change_access_key { -- cgit v1.2.3-70-g09d2 From 9598a855fa55f9f126f099a4ab792335d2dc1a69 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 25 May 2019 10:24:43 +0200 Subject: aws: check for existence of config file in aws_profiles Fixes #7872 --- plugins/aws/aws.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d70a64fcc..b78cd2ac1 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -33,6 +33,7 @@ function aws_change_access_key { } function aws_profiles { + [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) } compctl -K aws_profiles asp aws_change_access_key -- cgit v1.2.3-70-g09d2 From 1343ab67edd8a81b75aceca77ddb526be87a20c1 Mon Sep 17 00:00:00 2001 From: programmer04 Date: Sun, 26 May 2019 12:31:37 +0200 Subject: aws: check availability of aws profiles (#7839) --- plugins/aws/aws.plugin.zsh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index b78cd2ac1..5f5bf9bbb 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,29 +1,35 @@ -# AWS profile selection - -function agp { +agp() { echo $AWS_PROFILE } -function asp { +# AWS profile selection +asp() { if [[ -z "$1" ]]; then unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE echo AWS profile cleared. return fi + local available_profiles=($(aws_profiles)) + if [[ -z "${available_profiles[(r)$1]}" ]]; then + echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 + echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 + return 1 + fi + export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 export AWS_EB_PROFILE=$1 } -function aws_change_access_key { - if [[ -z "$1" ]] then +aws_change_access_key() { + if [[ -z "$1" ]]; then echo "usage: $0 " return 1 fi echo Insert the credentials when asked. - asp "$1" + asp "$1" || return 1 aws iam create-access-key aws configure --profile "$1" @@ -32,16 +38,18 @@ function aws_change_access_key { aws iam list-access-keys } -function aws_profiles { +aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' } -compctl -K aws_profiles asp aws_change_access_key +_aws_profiles() { + reply=($(aws_profiles)) +} +compctl -K _aws_profiles asp aws_change_access_key # AWS prompt - -function aws_prompt_info() { +aws_prompt_info() { [[ -z $AWS_PROFILE ]] && return echo "${ZSH_THEME_AWS_PREFIX:=}" } -- cgit v1.2.3-70-g09d2 From 9930dd6e49df5630ac23c68b85465f0bb801d17f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 28 May 2019 15:33:02 +0200 Subject: aws: use function keyword in function definitions Fixes #7886 --- plugins/aws/aws.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/aws') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 5f5bf9bbb..231ac5ad2 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,9 +1,9 @@ -agp() { +function agp() { echo $AWS_PROFILE } # AWS profile selection -asp() { +function asp() { if [[ -z "$1" ]]; then unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE echo AWS profile cleared. @@ -22,7 +22,7 @@ asp() { export AWS_EB_PROFILE=$1 } -aws_change_access_key() { +function aws_change_access_key() { if [[ -z "$1" ]]; then echo "usage: $0 " return 1 @@ -38,18 +38,18 @@ aws_change_access_key() { aws iam list-access-keys } -aws_profiles() { +function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' } -_aws_profiles() { +function _aws_profiles() { reply=($(aws_profiles)) } compctl -K _aws_profiles asp aws_change_access_key # AWS prompt -aws_prompt_info() { +function aws_prompt_info() { [[ -z $AWS_PROFILE ]] && return echo "${ZSH_THEME_AWS_PREFIX:=}" } @@ -61,7 +61,7 @@ fi # Load awscli completions -_awscli-homebrew-installed() { +function _awscli-homebrew-installed() { # check if Homebrew is installed (( $+commands[brew] )) || return 1 -- cgit v1.2.3-70-g09d2