1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-01 00:21:13 +00:00
prezto/modules/aws/functions/aws-info
2020-12-17 13:24:41 +01:00

34 lines
956 B
Plaintext

#
# Exposes information about the AWS_PROFILE environment via the $aws_info associative
# array.
#
# function aws-info {
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_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_prompt:t}${aws_region_prompt}"
aws_info[profile]="$profile_formatted"
fi
# }