2019-11-06 16:28:19 +00:00
|
|
|
#
|
|
|
|
# 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
|
2019-11-06 16:28:19 +00:00
|
|
|
|
|
|
|
unset aws_info
|
|
|
|
typeset -gA aws_info
|
|
|
|
|
2020-12-17 12:24:41 +00:00
|
|
|
if (( ${+AWS_SECRET_ACCESS_KEY} )); then
|
2021-03-05 16:06:47 +00:00
|
|
|
aws_prompt="${AWS_PROFILE} "
|
2020-12-17 12:24:41 +00:00
|
|
|
elif (( ${+AWS_PROFILE} )); then
|
|
|
|
aws_prompt=$AWS_PROFILE
|
2021-03-05 16:06:47 +00:00
|
|
|
fi
|
2019-11-06 16:28:19 +00:00
|
|
|
|
2021-03-05 16:06:47 +00:00
|
|
|
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-02-20 17:43:05 +00:00
|
|
|
|
2020-12-17 12:24:41 +00:00
|
|
|
if (( ${+AWS_SECRET_ACCESS_KEY} )) || (( ${+AWS_DEFAULT_REGION} )); then
|
2019-11-06 16:28:19 +00:00
|
|
|
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}"
|
2019-11-06 16:28:19 +00:00
|
|
|
aws_info[profile]="$profile_formatted"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# }
|