aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-03-18 21:52:53 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-03-18 21:52:53 +0300
commit1164e3e2a2154b821174ce5ded1fd3854c9134d8 (patch)
tree62ea3141cafedebca82506864622410ddb0e7eb1
parentb55cf134d6d21cc7902b8c3bb53b959169e25573 (diff)
add caching to simple_dir
-rwxr-xr-xpowerlevel9k.zsh-theme17
1 files changed, 13 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 4a0c0a96..301693de 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1271,10 +1271,19 @@ prompt_root_indicator() {
# This segment is a demo. It can disappear any time. Use prompt_dir instead.
prompt_simple_dir() {
- $1_prompt_segment $0_HOME $2 blue "$DEFAULT_COLOR" "%~" HOME_ICON 0 '${$((!${#${(%)${:-%~}}:#\~})):#0}'
- $1_prompt_segment $0_HOME_SUBFOLDER $2 blue "$DEFAULT_COLOR" "%~" HOME_SUB_ICON 0 '${$((!${#${(%)${:-%~}}:#\~?*})):#0}'
- $1_prompt_segment $0_ETC $2 blue "$DEFAULT_COLOR" "%~" ETC_ICON 0 '${$((!${#${(%)${:-%~}}:#/etc*})):#0}'
- $1_prompt_segment $0_DEFAULT $2 blue "$DEFAULT_COLOR" "%~" FOLDER_ICON 0 '${${${(%)${:-%~}}:#\~*}:#/etc*}'
+ if ! _p9k_cache_get "$0" "$1" "$2" ; then
+ local p=$_P9K_PROMPT
+ local key=$_P9K_CACHE_KEY
+ _P9K_PROMPT=''
+ $1_prompt_segment $0_HOME $2 blue "$DEFAULT_COLOR" "%~" HOME_ICON 0 '${$((!${#${(%)${:-%~}}:#\~})):#0}'
+ $1_prompt_segment $0_HOME_SUBFOLDER $2 blue "$DEFAULT_COLOR" "%~" HOME_SUB_ICON 0 '${$((!${#${(%)${:-%~}}:#\~?*})):#0}'
+ $1_prompt_segment $0_ETC $2 blue "$DEFAULT_COLOR" "%~" ETC_ICON 0 '${$((!${#${(%)${:-%~}}:#/etc*})):#0}'
+ $1_prompt_segment $0_DEFAULT $2 blue "$DEFAULT_COLOR" "%~" FOLDER_ICON 0 '${${${(%)${:-%~}}:#\~*}:#/etc*}'
+ _P9K_CACHE_KEY=$key
+ _p9k_cache_set "$_P9K_PROMPT"
+ _P9K_PROMPT=$p
+ fi
+ _P9K_PROMPT+=${_P9K_CACHE_VAL[1]}
}
################################################################