1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 17:28:01 +00:00
prezto/modules/aws/functions/aws-info

34 lines
949 B
Plaintext
Raw Permalink Normal View History

#
# Exposes information about the AWS_PROFILE environment via the $aws_info associative
# array.
#
# function aws-info {
local profile_format
local profile_formatted
2020-12-17 12:24:41 +00:00
local aws_prompt
local aws_region_prompt
unset aws_info
typeset -gA aws_info
2020-12-17 12:24:41 +00:00
if (( ${+AWS_SECRET_ACCESS_KEY} )); then
aws_prompt="${AWS_PROFILE}  "
2020-12-17 12:24:41 +00:00
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"
2020-12-17 12:24:41 +00:00
fi
2020-12-17 12:24:41 +00:00
if (( ${+AWS_SECRET_ACCESS_KEY} )) || (( ${+AWS_DEFAULT_REGION} )); then
zstyle -s ':prezto:module:aws:info:profile' format 'profile_format'
2020-12-17 12:24:41 +00:00
zformat -f profile_formatted "$profile_format" "v:${aws_prompt:t}${aws_region_prompt}"
aws_info[profile]="$profile_formatted"
fi
# }