aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorAlex Jurkiewicz <alex@jurkiewi.cz>2021-05-28 07:25:39 +0300
committerAlex Jurkiewicz <alex@jurkiewi.cz>2021-05-28 07:25:39 +0300
commitaa4d36634132b6c510207e6cdbc6d1aceaf7ddbd (patch)
tree0e1b8e8ecae3a094c588421654e858013913d8cb /internal/p10k.zsh
parent35acee119d2d18aa4630a63f36cb5b447bd17637 (diff)
Add region support for aws element
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh23
1 files changed, 22 insertions, 1 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 8ceaaffb..424eb9b3 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1131,6 +1131,25 @@ _p9k_prompt_anaconda_init() {
# AWS Profile
prompt_aws() {
local aws_profile="${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}"
+ local text="${aws_profile//\%/%%}"
+ if (( _POWERLEVEL9K_AWS_SHOW_REGION )); then
+ local region_full
+ if [[ -v $AWS_DEFAULT_REGION ]]; then
+ region_full=$AWS_DEFAULT_REGION
+ else
+ if ! _p9k_cache_get "$0-$aws_profile-full"; then
+ _p9k_cache_set $(aws configure get region)
+ fi
+ region_full=$_p9k__cache_val[1]
+ fi
+ if (( _POWERLEVEL9K_AWS_SHOW_REGION_SHORT )); then
+ local region_short=${${${${${${region_full//-}//north/n}//south/s}//east/e}//west/w}//gov/g}
+ text="$text ($region_short)"
+ else
+ text="$text ($region_full)"
+ fi
+ fi
+
local pat class
for pat class in "${_POWERLEVEL9K_AWS_CLASSES[@]}"; do
if [[ $aws_profile == ${~pat} ]]; then
@@ -1138,7 +1157,7 @@ prompt_aws() {
break
fi
done
- _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "${aws_profile//\%/%%}"
+ _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "$text"
}
_p9k_prompt_aws_init() {
@@ -7379,6 +7398,8 @@ _p9k_init_params() {
# POWERLEVEL9K_KUBECONTEXT_OTHER_BACKGROUND=yellow
_p9k_declare -a POWERLEVEL9K_KUBECONTEXT_CLASSES --
_p9k_declare -a POWERLEVEL9K_AWS_CLASSES --
+ _p9k_declare -b POWERLEVEL9K_AWS_SHOW_REGION 0
+ _p9k_declare -b POWERLEVEL9K_AWS_SHOW_REGION_SHORT 1
_p9k_declare -a POWERLEVEL9K_AZURE_CLASSES --
_p9k_declare -a POWERLEVEL9K_TERRAFORM_CLASSES --
_p9k_declare -b POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT 0