Allow setting a cache file name suffix, e.g. "-${TERM}"

When mixing tmux (TERM=tmux-256color) and native terminal windows/tabs
(e.g. TERM=xterm-kitty), since they share the same instant prompt cache
files, the cache files are invalidated every time I start a new Zsh in a
different $TERM [1].

People who have this issue can set _P10K_CACHE_SUFFIX="-${TERM}" to work
around it.

[1] e2db860745
This commit is contained in:
Frederick Zhang 2024-06-17 10:23:09 +10:00
commit 82fdf6848d
No known key found for this signature in database
GPG key ID: 980A192C361BE1AE
3 changed files with 7 additions and 7 deletions

View file

@ -6161,7 +6161,7 @@ _p9k_dump_instant_prompt() {
local user=${(%):-%n}
local root_dir=${__p9k_dump_file:h}
local prompt_dir=${root_dir}/p10k-$user
local root_file=$root_dir/p10k-instant-prompt-$user.zsh
local root_file=$root_dir/p10k-instant-prompt-$user${_P10K_CACHE_SUFFIX}.zsh
local prompt_file=$prompt_dir/prompt-${#_p9k__cwd}
[[ -d $prompt_dir ]] || mkdir -p $prompt_dir || return
[[ -w $root_dir && -w $prompt_dir ]] || return
@ -6461,7 +6461,7 @@ _p9k_dump_instant_prompt() {
else
local tmpdir=/tmp
fi
typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}-$$
typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}${_P10K_CACHE_SUFFIX}-$$
{ : > $__p9k_instant_prompt_output } || return
print -rn -- "${out}${esc}?2004h" || return
if (( $+commands[stty] )); then
@ -6476,7 +6476,7 @@ _p9k_dump_instant_prompt() {
typeset -g _z4h_saved_screen
-z4h-save-screen
fi
typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh
typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}${_P10K_CACHE_SUFFIX}.zsh
if builtin source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
_p9k_preinit
fi