mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-25 00:21:58 +00:00
BREAKING CHANGE: add classes to google_app_cred and change its default content
This commit is contained in:
parent
e2c46f0dfc
commit
e45af961da
4 changed files with 133 additions and 83 deletions
|
@ -770,32 +770,46 @@
|
|||
# Custom icon.
|
||||
# typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
##########[ gcloud: google cloud acccount and project (https://cloud.google.com/) ]###########
|
||||
# Google cloud color.
|
||||
typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32
|
||||
|
||||
# Google cloud format. Uncomment POWERLEVEL9K_GCLOUD_CONTENT_EXPANSION and edit its value if the
|
||||
# default is too verbose.
|
||||
#
|
||||
# P9K_GCLOUD_ACCOUNT: the output of `gcloud config get-value account`
|
||||
# P9K_GCLOUD_PROJECT: the output of `gcloud config get-value project`
|
||||
# ${VARIABLE//\%/%%}: ${VARIABLE} with all occurences of '%' replaced with '%%'.
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GCLOUD_CONTENT_EXPANSION='${P9K_GCLOUD_ACCOUNT//\%/%%}:${P9K_GCLOUD_PROJECT//\%/%%}'
|
||||
|
||||
# Custom icon.
|
||||
# typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
#[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]#
|
||||
# Default google application credentials color.
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_FOREGROUND=32
|
||||
# Google application credentials color for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_FOREGROUND=32
|
||||
# Google application credentials classes for the purpose of using different colors, icons and
|
||||
# expansions with different credentials.
|
||||
#
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first
|
||||
# element in each pair defines a pattern against which the current kubernetes context 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_GOOGLE_APP_CRED_*CONTENT_EXPANSION
|
||||
# parameters, you'll see this value in your prompt. The second element of each pair in
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order.
|
||||
# The first match wins.
|
||||
#
|
||||
# For example, given these settings:
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD
|
||||
# '*:*test*:*' TEST
|
||||
# '*' DEFAULT)
|
||||
#
|
||||
# If your current Google application credentials is "service_account deathray-testing x@y.com",
|
||||
# its class is TEST because it 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_GOOGLE_APP_CRED_TEST_FOREGROUND=28
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID'
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD # These values are examples that are unlikely
|
||||
# '*:*test*:*' TEST # to match your needs. Customize them as needed.
|
||||
'*' DEFAULT)
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
# Google application credentials format. Uncomment POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION
|
||||
# and edit its value if the default is too verbose. You can use the following parameters in the
|
||||
# expansion. Each of them corresponds to one of the fields in the JSON file pointed to by
|
||||
# GOOGLE_APPLICATION_CREDENTIALS.
|
||||
# Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by
|
||||
# google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
|
||||
#
|
||||
# You can use the following parameters in the expansion. Each of them corresponds to one of the
|
||||
# fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS.
|
||||
#
|
||||
# Parameter | JSON key file field
|
||||
# ---------------------------------+---------------
|
||||
|
@ -803,18 +817,8 @@
|
|||
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
|
||||
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
|
||||
#
|
||||
# Note: ${VARIABLE%%.*} expands to ${VARIABLE} up to but not including the first period ('.').
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION='${${P9K_GOOGLE_APP_CRED_CLIENT_EMAIL%%.*}//\%/%%}'
|
||||
#
|
||||
# You can also define content expansion specifically for service accounts by defining
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_CONTENT_EXPANSION.
|
||||
|
||||
# Default google application credentials icon.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Google application credentials icon for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}'
|
||||
|
||||
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
|
||||
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
|
||||
|
|
|
@ -844,15 +844,45 @@
|
|||
# typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
#[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]#
|
||||
# Default google application credentials color.
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_FOREGROUND=32
|
||||
# Google application credentials color for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_FOREGROUND=32
|
||||
# Google application credentials classes for the purpose of using different colors, icons and
|
||||
# expansions with different credentials.
|
||||
#
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first
|
||||
# element in each pair defines a pattern against which the current kubernetes context 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_GOOGLE_APP_CRED_*CONTENT_EXPANSION
|
||||
# parameters, you'll see this value in your prompt. The second element of each pair in
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order.
|
||||
# The first match wins.
|
||||
#
|
||||
# For example, given these settings:
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD
|
||||
# '*:*test*:*' TEST
|
||||
# '*' DEFAULT)
|
||||
#
|
||||
# If your current Google application credentials is "service_account deathray-testing x@y.com",
|
||||
# its class is TEST because it 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_GOOGLE_APP_CRED_TEST_FOREGROUND=28
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID'
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD # These values are examples that are unlikely
|
||||
# '*:*test*:*' TEST # to match your needs. Customize them as needed.
|
||||
'*' DEFAULT)
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
# Google application credentials format. Uncomment POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION
|
||||
# and edit its value if the default is too verbose. You can use the following parameters in the
|
||||
# expansion. Each of them corresponds to one of the fields in the JSON file pointed to by
|
||||
# GOOGLE_APPLICATION_CREDENTIALS.
|
||||
# Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by
|
||||
# google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
|
||||
#
|
||||
# You can use the following parameters in the expansion. Each of them corresponds to one of the
|
||||
# fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS.
|
||||
#
|
||||
# Parameter | JSON key file field
|
||||
# ---------------------------------+---------------
|
||||
|
@ -860,18 +890,8 @@
|
|||
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
|
||||
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
|
||||
#
|
||||
# Note: ${VARIABLE%%.*} expands to ${VARIABLE} up to but not including the first period ('.').
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION='${${P9K_GOOGLE_APP_CRED_CLIENT_EMAIL%%.*}//\%/%%}'
|
||||
#
|
||||
# You can also define content expansion specifically for service accounts by defining
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_CONTENT_EXPANSION.
|
||||
|
||||
# Default google application credentials icon.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Google application credentials icon for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}'
|
||||
|
||||
###############################[ public_ip: public IP address ]###############################
|
||||
# Public IP color.
|
||||
|
|
|
@ -812,17 +812,46 @@
|
|||
# typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
#[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]#
|
||||
# Default google application credentials color.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_FOREGROUND=7
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_BACKGROUND=4
|
||||
# Google application credentials color for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_FOREGROUND=7
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_BACKGROUND=4
|
||||
# Google application credentials classes for the purpose of using different colors, icons and
|
||||
# expansions with different credentials.
|
||||
#
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first
|
||||
# element in each pair defines a pattern against which the current kubernetes context 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_GOOGLE_APP_CRED_*CONTENT_EXPANSION
|
||||
# parameters, you'll see this value in your prompt. The second element of each pair in
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order.
|
||||
# The first match wins.
|
||||
#
|
||||
# For example, given these settings:
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD
|
||||
# '*:*test*:*' TEST
|
||||
# '*' DEFAULT)
|
||||
#
|
||||
# If your current Google application credentials is "service_account deathray-testing x@y.com",
|
||||
# its class is TEST because it 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_GOOGLE_APP_CRED_TEST_FOREGROUND=28
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID'
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
|
||||
# '*:*prod*:*' PROD # These values are examples that are unlikely
|
||||
# '*:*test*:*' TEST # to match your needs. Customize them as needed.
|
||||
'*' DEFAULT)
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=7
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_BACKGROUND=4
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
|
||||
# Google application credentials format. Uncomment POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION
|
||||
# and edit its value if the default is too verbose. You can use the following parameters in the
|
||||
# expansion. Each of them corresponds to one of the fields in the JSON file pointed to by
|
||||
# GOOGLE_APPLICATION_CREDENTIALS.
|
||||
# Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by
|
||||
# google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
|
||||
#
|
||||
# You can use the following parameters in the expansion. Each of them corresponds to one of the
|
||||
# fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS.
|
||||
#
|
||||
# Parameter | JSON key file field
|
||||
# ---------------------------------+---------------
|
||||
|
@ -830,18 +859,8 @@
|
|||
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
|
||||
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
|
||||
#
|
||||
# Note: ${VARIABLE%%.*} expands to ${VARIABLE} up to but not including the first period ('.').
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION='${${P9K_GOOGLE_APP_CRED_CLIENT_EMAIL%%.*}//\%/%%}'
|
||||
#
|
||||
# You can also define content expansion specifically for service accounts by defining
|
||||
# POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_CONTENT_EXPANSION.
|
||||
|
||||
# Default google application credentials icon.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Google application credentials icon for service accounts.
|
||||
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SERVICE_ACCOUNT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
|
||||
typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}'
|
||||
|
||||
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
|
||||
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
|
||||
|
|
|
@ -3397,7 +3397,15 @@ prompt_google_app_cred() {
|
|||
local -a lines
|
||||
local q='[.type//"", .project_id//"", .client_email//"", 0][]'
|
||||
if lines=("${(@f)$(jq -r $q <$GOOGLE_APPLICATION_CREDENTIALS 2>/dev/null)}") && (( $#lines == 4 )); then
|
||||
_p9k_cache_stat_set 1 "${(@)lines[1,-2]}"
|
||||
local text="${(j.:.)lines[1,-2]}"
|
||||
local pat class state
|
||||
for pat class in "${_POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES[@]}"; do
|
||||
if [[ $text == ${~pat} ]]; then
|
||||
[[ -n $class ]] && state=_${(U)class}
|
||||
break
|
||||
fi
|
||||
done
|
||||
_p9k_cache_stat_set 1 "${(@)lines[1,-2]}" "$text" "$state"
|
||||
else
|
||||
_p9k_cache_stat_set 0
|
||||
fi
|
||||
|
@ -3407,9 +3415,7 @@ prompt_google_app_cred() {
|
|||
P9K_GOOGLE_APP_CRED_TYPE=$_p9k_cache_val[2]
|
||||
P9K_GOOGLE_APP_CRED_PROJECT_ID=$_p9k_cache_val[3]
|
||||
P9K_GOOGLE_APP_CRED_CLIENT_EMAIL=$_p9k_cache_val[4]
|
||||
|
||||
[[ -n $P9K_GOOGLE_APP_CRED_TYPE ]] && local state=_${(U)P9K_GOOGLE_APP_CRED_TYPE} || local state
|
||||
_p9k_prompt_segment "$0$state" "blue" "white" "GCLOUD_ICON" 0 '' "${${P9K_GOOGLE_APP_CRED_CLIENT_EMAIL%%.*}//\%/%%}"
|
||||
_p9k_prompt_segment "$0$_p9k_cache_val[6]" "blue" "white" "GCLOUD_ICON" 0 '' "$_p9k_cache_val[5]"
|
||||
}
|
||||
|
||||
typeset -gra __p9k_nordvpn_tag=(
|
||||
|
@ -5016,6 +5022,7 @@ _p9k_init_params() {
|
|||
# POWERLEVEL9K_KUBECONTEXT_OTHER_BACKGROUND=yellow
|
||||
_p9k_declare -a POWERLEVEL9K_KUBECONTEXT_CLASSES --
|
||||
_p9k_declare -a POWERLEVEL9K_AWS_CLASSES --
|
||||
_p9k_declare -a POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES -- 'service_account:*' SERVICE_ACCOUNT
|
||||
# Specifies the format of java version.
|
||||
#
|
||||
# POWERLEVEL9K_JAVA_VERSION_FULL=true => 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03
|
||||
|
@ -5513,7 +5520,7 @@ _p9k_must_init() {
|
|||
[[ $sig == $_p9k__param_sig ]] && return 1
|
||||
_p9k_deinit
|
||||
fi
|
||||
_p9k__param_pat=$'v17\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
||||
_p9k__param_pat=$'v18\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
||||
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
|
||||
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
|
||||
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'
|
||||
|
|
Loading…
Reference in a new issue