1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-14 23:31:12 +00:00
prezto/modules/aws/functions/aws-info

34 lines
949 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="${AWS_PROFILE}  "
elif (( ${+AWS_PROFILE} )); then
aws_prompt=$AWS_PROFILE
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
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
# }