mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-16 17:50:09 +00:00
support POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
This commit is contained in:
parent
bab487aa6e
commit
ba39eb3421
1 changed files with 19 additions and 10 deletions
|
@ -1153,20 +1153,19 @@ prompt_public_ip() {
|
||||||
prompt_context() {
|
prompt_context() {
|
||||||
if ! _p9k_cache_get $0 "${(%):-%#}"; then
|
if ! _p9k_cache_get $0 "${(%):-%#}"; then
|
||||||
local -i enabled=1
|
local -i enabled=1
|
||||||
local content='' state=''
|
local content
|
||||||
if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 1 || -z $DEFAULT_USER || $_P9K_SSH == 1 ]]; then
|
if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $_P9K_SSH == 0 ]]; then
|
||||||
content=$_POWERLEVEL9K_CONTEXT_TEMPLATE
|
|
||||||
else
|
|
||||||
local user="$(whoami)"
|
local user="$(whoami)"
|
||||||
if [[ $user != $DEFAULT_USER ]]; then
|
if [[ $user == $DEFAULT_USER ]]; then
|
||||||
content=$_POWERLEVEL9K_CONTEXT_TEMPLATE
|
if (( _POWERLEVEL9K_ALWAYS_SHOW_USER )); then
|
||||||
elif (( _POWERLEVEL9K_ALWAYS_SHOW_USER )); then
|
|
||||||
content="${user//\%/%%}"
|
content="${user//\%/%%}"
|
||||||
else
|
else
|
||||||
enabled=0
|
enabled=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local state
|
||||||
if (( enabled )); then
|
if (( enabled )); then
|
||||||
state="DEFAULT"
|
state="DEFAULT"
|
||||||
if [[ "${(%):-%#}" == '#' ]]; then
|
if [[ "${(%):-%#}" == '#' ]]; then
|
||||||
|
@ -1180,6 +1179,16 @@ prompt_context() {
|
||||||
elif [[ -n "$SUDO_COMMAND" ]]; then
|
elif [[ -n "$SUDO_COMMAND" ]]; then
|
||||||
state="SUDO"
|
state="SUDO"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $content ]]; then
|
||||||
|
local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
||||||
|
if (( $+parameters[$var] )); then
|
||||||
|
content=${(P)var}
|
||||||
|
content=${(g::)content}
|
||||||
|
else
|
||||||
|
content=$_POWERLEVEL9K_CONTEXT_TEMPLATE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_p9k_cache_set "$enabled" "$state" "$content"
|
_p9k_cache_set "$enabled" "$state" "$content"
|
||||||
|
|
Loading…
Reference in a new issue