From d17f22e5b0f803c7b95eb379be0a810552a3a30a Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 20 Oct 2019 10:36:41 +0200 Subject: [PATCH] better handling of XDG_CACHE_HOME changes --- internal/p10k.zsh | 13 +++++++++---- powerlevel10k.zsh-theme | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index a24910b4..69846a53 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3577,6 +3577,10 @@ _p9k_dump_instant_prompt() { exec {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 1>$__p9k_instant_prompt_output exec 2>&1 typeset -gi __p9k_instant_prompt_active=1 + typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh + if source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + _p9k_preinit + fi function _p9k_instant_prompt_precmd_first() { emulate -L zsh function _p9k_instant_prompt_sched_last() { @@ -3600,10 +3604,7 @@ _p9k_dump_instant_prompt() { precmd_functions=(${(@)precmd_functions:#_p9k_instant_prompt_precmd_first}) } precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions) - typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh - if source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then - _p9k_preinit - fi + } && unsetopt prompt_cr prompt_sp || true' } always { exec {fd}>&- @@ -5346,5 +5347,9 @@ zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket zmodload -F zsh/files b:zf_mv b:zf_rm +if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then + zf_rm -f $__p9k_instant_prompt_dump_file 2>/dev/null +fi + _p9k_init_ssh prompt_powerlevel9k_setup diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme index 1808552c..b2bb0954 100644 --- a/powerlevel10k.zsh-theme +++ b/powerlevel10k.zsh-theme @@ -27,7 +27,7 @@ return fi typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh - if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && (( ! $+functions[_p9k_preinit] )) && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then _p9k_preinit fi typeset -gr __p9k_sourced=1