From 3d827cdb8845c19c82fe13637a77923ece3c7f58 Mon Sep 17 00:00:00 2001 From: dcarrillo Date: Thu, 20 Feb 2020 18:43:05 +0100 Subject: [PATCH] [aws] Add support for showing AWS region in prompt --- modules/aws/functions/aws-info | 9 +++++++-- modules/aws/init.zsh | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/aws/functions/aws-info b/modules/aws/functions/aws-info index b38e1e5..546b445 100644 --- a/modules/aws/functions/aws-info +++ b/modules/aws/functions/aws-info @@ -12,9 +12,14 @@ unset aws_info typeset -gA aws_info -if [[ -n "$AWS_PROFILE" ]]; then +if (( ${+AWS_PROFILE} )); then + if (( ${+AWS_DEFAULT_REGION+1} )) && [[ ${_aws_region} = "true" ]]; then + AWS_REGION=$(cut -d "-" -f 1 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 2 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 3 <<<$AWS_DEFAULT_REGION | cut -b 1) + AWS_REGION_PROMPT=" $AWS_REGION" + fi + zstyle -s ':prezto:module:aws:info:profile' format 'profile_format' - zformat -f profile_formatted "$profile_format" "v:${AWS_PROFILE:t}" + zformat -f profile_formatted "$profile_format" "v:${AWS_PROFILE:t}${AWS_REGION_PROMPT}" aws_info[profile]="$profile_formatted" fi diff --git a/modules/aws/init.zsh b/modules/aws/init.zsh index 1daa4d6..5271b75 100644 --- a/modules/aws/init.zsh +++ b/modules/aws/init.zsh @@ -7,6 +7,7 @@ # Get the output parameter zstyle -s ':prezto:module:aws' output '_aws_output' || _aws_output='table' +zstyle -s ':prezto:module:aws' show_region '_aws_region' || _aws_region='false' zstyle -s ':prezto:module:aws' profile '_aws_profile' || _aws_profile='default' # Return if requirements are not found.