aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-07-06 20:55:08 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-07-06 20:55:08 +0300
commitd8cfba357ebb5640fe3d208a1c1223881342518f (patch)
treea0e5aef0c9a1e3e8cf273c319e6f74fe8d458506 /internal/p10k.zsh
parent214d12b27581f29ad1d8807e57bf8818160ef61b (diff)
add POWERLEVEL9K_${segment}_${state}_CONTENT_TRANSFORMER parameter
Diffstat (limited to 'internal/p10k.zsh')
-rwxr-xr-xinternal/p10k.zsh47
1 files changed, 25 insertions, 22 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 825fd772..8fce48df 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -208,24 +208,25 @@ left_prompt_segment() {
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
- _p9k_cache_set $has_icon $_P9K_RETVAL $pre $post
+ local tr=POWERLEVEL9K_${(U)${1}#prompt_}_CONTENT_TRANSFORMER
+ (( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}'
+
+ local post="\${_P9K_C}$style$space\${\${_P9K_I::=$2}+}\${\${_P9K_BG::=$bg_color}+}}"
+
+ _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.
@@ -289,25 +290,27 @@ 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}+}}"
+ local style=$_P9K_RETVAL
- _p9k_cache_set $has_icon $_P9K_RETVAL $pre $post
+ local tr=POWERLEVEL9K_${(U)${1}#prompt_}_CONTENT_TRANSFORMER
+ (( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}'
+
+ local post="$icon$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() {