From d435235c29c0966295018fe15c64717436f909f6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 20:14:16 +0200 Subject: take advantage of async gitstatus start to make p10k startup faster --- powerlevel9k.zsh-theme | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'powerlevel9k.zsh-theme') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9d2847ce..5fc89041 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,7 +17,8 @@ [[ ! -o 'no_brace_expand' ]] || _p9k_src_opts+=('no_brace_expand') 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' -typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" +typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} +typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh () { emulate -L zsh @@ -27,10 +28,15 @@ typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" return fi typeset -gr __p9k_sourced=1 - local f - for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do - [[ $f.zwc -nt $f ]] || zcompile $f - done + if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then + local f + for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do + [[ $f.zwc -nt $f ]] || zcompile $f + done + fi + if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + _p9k_preinit + fi source $__p9k_root_dir/internal/p10k.zsh || true } -- cgit v1.2.3