clean up the handling of POWERLEVEL9K_AZURE_CLASSES and put it in all configs (#2379)

This reverts commit 343d4f44e5, reversing
changes made to 4dca4bdfbb.
pull/2385/head
Roman Perepelitsa 1 year ago
parent 343d4f44e5
commit 078497570f

@ -1406,11 +1406,11 @@
typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt'
# POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current AZURE subscription gets matched. # in each pair defines a pattern against which the current azure account name gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
# that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters, # that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters,
# you'll see this value in your prompt. The second element of each pair in # you'll see this value in your prompt. The second element of each pair in
# POWERLEVEL9K_AZURE_CLASSES defines the profile class. Patterns are tried in order. The # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The
# first match wins. # first match wins.
# #
# For example, given these settings: # For example, given these settings:
@ -1418,10 +1418,10 @@
# typeset -g POWERLEVEL9K_AZURE_CLASSES=( # typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD # '*prod*' PROD
# '*test*' TEST # '*test*' TEST
# '*' DEFAULT) # '*' OTHER)
# #
# If your current AZURE subscription is "company_test", its class is TEST # If your current azure account is "project_test", its class is TEST because "project_test"
# because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. # doesn't match the pattern '*prod*' but does match '*test*'.
# #
# You can define different colors, icons and content expansions for different classes: # You can define different colors, icons and content expansions for different classes:
# #
@ -1431,10 +1431,12 @@
typeset -g POWERLEVEL9K_AZURE_CLASSES=( typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely # '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed. # '*test*' TEST # to match your needs. Customize them as needed.
'*' DEFAULT) '*' OTHER)
typeset -g POWERLEVEL9K_AZURE_DEFAULT_FOREGROUND=32
# Azure account name color.
typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
# Show gcloud only when the command you are typing invokes one of these tools. # Show gcloud only when the command you are typing invokes one of these tools.

@ -1382,10 +1382,39 @@
# Show azure only when the command you are typing invokes one of these tools. # Show azure only when the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show azure. # Tip: Remove the next line to always show azure.
typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt'
# POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current azure account name gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
# that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters,
# you'll see this value in your prompt. The second element of each pair in
# POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The
# first match wins.
#
# For example, given these settings:
#
# typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
# '*' OTHER)
#
# If your current azure account is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
#
# You can define different colors, icons and content expansions for different classes:
#
# typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=2
# typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
'*' OTHER)
# Azure account name color. # Azure account name color.
typeset -g POWERLEVEL9K_AZURE_FOREGROUND=4 typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=4
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
# Show gcloud only when the command you are typing invokes one of these tools. # Show gcloud only when the command you are typing invokes one of these tools.

@ -1378,10 +1378,39 @@
# Show azure only when the command you are typing invokes one of these tools. # Show azure only when the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show azure. # Tip: Remove the next line to always show azure.
typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt'
# POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current azure account name gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
# that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters,
# you'll see this value in your prompt. The second element of each pair in
# POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The
# first match wins.
#
# For example, given these settings:
#
# typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
# '*' OTHER)
#
# If your current azure account is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
#
# You can define different colors, icons and content expansions for different classes:
#
# typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=28
# typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
'*' OTHER)
# Azure account name color. # Azure account name color.
typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
# Show gcloud only when the command you are typing invokes one of these tools. # Show gcloud only when the command you are typing invokes one of these tools.

@ -1482,11 +1482,41 @@
# Show azure only when the command you are typing invokes one of these tools. # Show azure only when the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show azure. # Tip: Remove the next line to always show azure.
typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt'
# POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current azure account name gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
# that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters,
# you'll see this value in your prompt. The second element of each pair in
# POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The
# first match wins.
#
# For example, given these settings:
#
# typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
# '*' OTHER)
#
# If your current azure account is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
#
# You can define different colors, icons and content expansions for different classes:
#
# typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=2
# typeset -g POWERLEVEL9K_AZURE_TEST_BACKGROUND=0
# typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
typeset -g POWERLEVEL9K_AZURE_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
'*' OTHER)
# Azure account name color. # Azure account name color.
typeset -g POWERLEVEL9K_AZURE_FOREGROUND=7 typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=7
typeset -g POWERLEVEL9K_AZURE_BACKGROUND=4 typeset -g POWERLEVEL9K_AZURE_OTHER_BACKGROUND=4
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
# Show gcloud only when the command you are typing invokes one of these tools. # Show gcloud only when the command you are typing invokes one of these tools.

@ -4643,9 +4643,10 @@ _p9k_prompt_java_version_init() {
} }
prompt_azure() { prompt_azure() {
local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json local name cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json
if ! _p9k_cache_stat_get $0 $cfg; then if _p9k_cache_stat_get $0 $cfg; then
local name name=$_p9k__cache_val[1]
else
if (( $+commands[jq] )) && name="$(jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null)"; then if (( $+commands[jq] )) && name="$(jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null)"; then
name=${name%%$'\n'*} name=${name%%$'\n'*}
elif ! name="$(az account show --query name --output tsv 2>/dev/null)"; then elif ! name="$(az account show --query name --output tsv 2>/dev/null)"; then
@ -4653,16 +4654,15 @@ prompt_azure() {
fi fi
_p9k_cache_stat_set "$name" _p9k_cache_stat_set "$name"
fi fi
[[ -n $name ]] || return
local pat class state local pat class state
for pat class in "${_POWERLEVEL9K_AZURE_CLASSES[@]}"; do for pat class in "${_POWERLEVEL9K_AZURE_CLASSES[@]}"; do
name="${_p9k__cache_val[1]//\%/%%}"
if [[ $name == ${~pat} ]]; then if [[ $name == ${~pat} ]]; then
[[ -n $class ]] && state=_${${(U)class}//İ/I} [[ -n $class ]] && state=_${${(U)class}//İ/I}
break break
fi fi
done done
[[ -n $_p9k__cache_val[1] ]] || return _p9k_prompt_segment "$0$state" "blue" "white" "AZURE_ICON" 0 '' "${name//\%/%%}"
_p9k_prompt_segment "$0$state" "blue" "white" "AZURE_ICON" 0 '' "${_p9k__cache_val[1]//\%/%%}"
} }
_p9k_prompt_azure_init() { _p9k_prompt_azure_init() {
@ -9375,7 +9375,7 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p
zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null
fi fi
typeset -g P9K_VERSION=1.19.1 typeset -g P9K_VERSION=1.19.2
unset VSCODE_SHELL_INTEGRATION unset VSCODE_SHELL_INTEGRATION
_p9k_init_ssh _p9k_init_ssh

Loading…
Cancel
Save