[aws] Update prompt

This commit is contained in:
Dani 2020-12-17 13:24:41 +01:00
parent 775f6123b2
commit c7ef9c1f46
2 changed files with 15 additions and 8 deletions

View File

@ -7,19 +7,26 @@
local profile_format
local profile_formatted
local aws_prompt
local aws_region_prompt
unset aws_info
typeset -gA aws_info
if (( ${+AWS_SECRET_ACCESS_KEY} )); then
aws_prompt='ACCESS_KEY'
elif (( ${+AWS_PROFILE} )); then
aws_prompt=$AWS_PROFILE
if (( ${+AWS_PROFILE} )); then
if (( ${+AWS_DEFAULT_REGION} )) && [[ ${_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
if (( ${+AWS_DEFAULT_REGION} )) && [[ ${_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
fi
if (( ${+AWS_SECRET_ACCESS_KEY} )) || (( ${+AWS_DEFAULT_REGION} )); then
zstyle -s ':prezto:module:aws:info:profile' format 'profile_format'
zformat -f profile_formatted "$profile_format" "v:${AWS_PROFILE:t}${AWS_REGION_PROMPT}"
zformat -f profile_formatted "$profile_format" "v:${aws_prompt:t}${aws_region_prompt}"
aws_info[profile]="$profile_formatted"
fi

View File

@ -154,6 +154,7 @@ function aws_switch_profile {
fi
echo "Activating profile $1..."
unset -m "AWS_*"
export AWS_PROFILE=$1
if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} ))
region=$(aws configure get region)
@ -167,6 +168,5 @@ function aws_switch_profile {
function aws_deactivate_profile {
echo "Deactivating aws profile..."
unset AWS_PROFILE
unset AWS_DEFAULT_REGION
unset -m "AWS_*"
}