summaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'internal/p10k.zsh')
-rwxr-xr-xinternal/p10k.zsh82
1 files changed, 49 insertions, 33 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index a1cbe3e0..96a28a46 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -170,7 +170,8 @@ left_prompt_segment() {
local glyph=$_P9K_RETVAL
_p9k_color $fg_color $1 VISUAL_IDENTIFIER_COLOR
_p9k_foreground $_P9K_RETVAL
- icon=$_P9K_RETVAL$glyph
+ _p9k_escape_rcurly %b$bg$_P9K_RETVAL$glyph
+ icon=$_P9K_RETVAL
has_icon=1
fi
fi
@@ -188,16 +189,16 @@ left_prompt_segment() {
# fi
local t=$#_P9K_T
- _P9K_T+=$line_start$bg$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS$icon # 1
- _P9K_T+=$bg$icon # 2
+ _P9K_T+=$line_start$bg$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS # 1
+ _P9K_T+=$bg # 2
if [[ -z $fg_color ]]; then
_p9k_foreground $DEFAULT_COLOR
- _P9K_T+=$bg$_P9K_RETVAL$subsep$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS$icon # 3
+ _P9K_T+=$bg$_P9K_RETVAL$subsep$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS # 3
else
- _P9K_T+=$bg$fg$subsep$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS$icon # 3
+ _P9K_T+=$bg$fg$subsep$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS # 3
fi
_p9k_get_icon LEFT_SEGMENT_SEPARATOR
- _P9K_T+=$bg$_P9K_RETVAL$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS$icon # 4
+ _P9K_T+=$bg$_P9K_RETVAL$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS # 4
local pre
pre+="\${_P9K_N::=}\${_P9K_F::=}"
@@ -205,27 +206,33 @@ left_prompt_segment() {
pre+="\${_P9K_N:=\${\${\$((_P9K_I>=$_P9K_LEFT_JOIN[$2])):#0}:+$((t+2))}}" # 2
pre+="\${_P9K_N:=\${\${\$((!\${#\${:-0\$_P9K_BG}:#0$bg_color})):#0}:+$((t+3))}}" # 3
pre+="\${_P9K_N:=\${\${_P9K_F::=%F{\$_P9K_BG\}}+$((t+4))}}}+}" # 4
- pre+="%b\${_P9K_F}\${_P9K_T[\$_P9K_N]}"
_p9k_escape_rcurly %b$bg$fg
- local post="\${_P9K_C}$_P9K_RETVAL$space\${\${_P9K_I::=$2}+}\${\${_P9K_BG::=$bg_color}+}}"
+ local style=$_P9K_RETVAL
+ local state=${(U)${1}#prompt_}
+
+ _p9k_get_icon ${state}_PREFIX
+ _p9k_escape_rcurly $_P9K_RETVAL
+ pre+="%b\${_P9K_F}\${_P9K_T[\$_P9K_N]}$_P9K_RETVAL$icon"
- _p9k_cache_set $has_icon $_P9K_RETVAL $pre $post
+ _p9k_get_icon ${state}_SUFFIX
+ _p9k_escape_rcurly $_P9K_RETVAL
+ local post="\${_P9K_C}$style$_P9K_RETVAL$style$space\${\${_P9K_I::=$2}+}\${\${_P9K_BG::=$bg_color}+}}"
+
+ local tr=POWERLEVEL9K_${state}_CONTENT_TRANSFORMER
+ (( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}'
+ _p9k_cache_set "$has_icon" "$style" "$tr" "$pre" "$post"
fi
- local name=$1
- local -i has_icon=${_P9K_CACHE_VAL[1]}
- local style=${_P9K_CACHE_VAL[2]}
local -i expand=$6
local cond=${7:-1}
shift 7
- local content="${(j::):-$style${^@}}"
- (( expand )) || content="\${(Q)\${:-${(qqq)${(q)content}}}}"
-
- _P9K_PROMPT+="\${\${:-$cond}:+\${\${:-\${_P9K_C::=${content}}${_P9K_CACHE_VAL[3]}"
- (( has_icon )) && _P9K_PROMPT+='${${(%):-$_P9K_C%1(l. .x)}[-1]%x}'
- _P9K_PROMPT+=${_P9K_CACHE_VAL[4]}
+ (( $6 )) || set -- "${:-\${\${P9K_CONTENT::=\${(Q)\${:-${(@qqq)^${(@q)@}}\}\}\}+\}}"
+ local content="${(j::):-${_P9K_CACHE_VAL[2]}${^@}${_P9K_CACHE_VAL[3]}}"
+ _P9K_PROMPT+="\${\${:-$cond}:+\${\${:-\${_P9K_C::=${content}}${_P9K_CACHE_VAL[4]}"
+ (( _P9K_CACHE_VAL[1] )) && _P9K_PROMPT+='${${(%):-$_P9K_C%1(l. .x)}[-1]%x}'
+ _P9K_PROMPT+=${_P9K_CACHE_VAL[5]}
}
# The same as left_prompt_segment above but for the right prompt.
@@ -281,7 +288,15 @@ right_prompt_segment() {
pre+="\${_P9K_N:=\${\${\$((!\${#\${:-0\$_P9K_BG}:#0$bg_color})):#0}:+$((t+3))}}" # 3
pre+="\${_P9K_N:=$((t+1))}}+}" # 4 == 1
(( _P9K_EMULATE_ZERO_RPROMPT_INDENT )) && pre+=' '
- pre+="\${_P9K_T[\$_P9K_N]}\${_P9K_C}$icon_style"
+
+ local state=${(U)${1}#prompt_}
+
+ _p9k_escape_rcurly %b$bg$fg
+ local style=$_P9K_RETVAL
+
+ _p9k_get_icon ${state}_PREFIX
+ _p9k_escape_rcurly $_P9K_RETVAL
+ pre+="\${_P9K_T[\$_P9K_N]}$_P9K_RETVAL$style\${_P9K_C}$icon_style"
if (( _P9K_EMULATE_ZERO_RPROMPT_INDENT )); then
local space=''
@@ -289,25 +304,26 @@ right_prompt_segment() {
_p9k_escape_rcurly $POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS
local space=$_P9K_RETVAL
fi
- _p9k_escape_rcurly %b$bg$fg
- local post="$icon$_P9K_RETVAL$space\${\${_P9K_I::=$2}+}\${\${_P9K_BG::=$bg_color}+}}"
- _p9k_cache_set $has_icon $_P9K_RETVAL $pre $post
+ local tr=POWERLEVEL9K_${state}_CONTENT_TRANSFORMER
+ (( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}'
+
+ _p9k_get_icon ${state}_SUFFIX
+ _p9k_escape_rcurly $_P9K_RETVAL
+ local post="$icon$style$_P9K_RETVAL$style$space\${\${_P9K_I::=$2}+}\${\${_P9K_BG::=$bg_color}+}}"
+
+ _p9k_cache_set "$has_icon" "$style" "$tr" "$pre" "$post"
fi
- local -i has_icon=${_P9K_CACHE_VAL[1]}
- local style=${_P9K_CACHE_VAL[2]}
local -i expand=$6
local cond=${7:-1}
shift 7
- _p9k_escape_rcurly $style
- local content="${(j::):-$_P9K_RETVAL${^@}}"
- (( expand )) || content="\${(Q)\${:-${(qqq)${(q)content}}}}"
-
- _P9K_PROMPT+="\${\${:-$cond}:+\${\${:-\${_P9K_C::=${content}}${_P9K_CACHE_VAL[3]}"
- (( has_icon )) && _P9K_PROMPT+='${${(%):-$_P9K_C%1(l. .x)}[-1]%x}'
- _P9K_PROMPT+=${_P9K_CACHE_VAL[4]}
+ (( expand )) || set -- "${:-\${\${P9K_CONTENT::=\${(Q)\${:-${(@qqq)^${(@q)@}}\}\}\}+\}}"
+ local content="${(j::):-${_P9K_CACHE_VAL[2]}${^@}${_P9K_CACHE_VAL[3]}}"
+ _P9K_PROMPT+="\${\${:-$cond}:+\${\${:-\${_P9K_C::=${content}}${_P9K_CACHE_VAL[4]}"
+ (( _P9K_CACHE_VAL[1] )) && _P9K_PROMPT+='${${(%):-$_P9K_C%1(l. .x)}[-1]%x}'
+ _P9K_PROMPT+=${_P9K_CACHE_VAL[5]}
}
function _p9k_python_version() {
@@ -2664,13 +2680,13 @@ _p9k_init() {
if (( _P9K_RETVAL == 1 && $#ruler_char == 1 )); then
_p9k_color "" prompt_ruler BACKGROUND
_p9k_background $_P9K_RETVAL
- _P9K_LEFT_PREFIX+=$_P9K_RETVAL
+ _P9K_LEFT_PREFIX+=%b$_P9K_RETVAL
_p9k_color "" prompt_ruler FOREGROUND
_p9k_foreground $_P9K_RETVAL
_P9K_LEFT_PREFIX+=$_P9K_RETVAL
[[ $ruler_char == '.' ]] && local sep=',' || local sep='.'
local ruler_len='${$((COLUMNS-_P9K_IND))/#-*/0}'
- _P9K_LEFT_PREFIX+="%b\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f"
+ _P9K_LEFT_PREFIX+="\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f"
_P9K_LEFT_PREFIX+='$_P9K_T[$((5+!_P9K_IND))]'
else
print -P "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered."