From 439ce3ed4ee21e2f4dd9c5972ede8223c0780010 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Mon, 14 Dec 2020 08:01:00 +0100 Subject: dir: add _NON_EXISTENT similarly to _NON_WRITABLE (requires POWERLEVEL9K_DIR_SHOW_WRITABLE=v3) See #1160. --- internal/p10k.zsh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'internal/p10k.zsh') diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 83091d0f..800168d0 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1901,8 +1901,12 @@ prompt_dir() { ;; esac - [[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE != 0 && ! -w $_p9k__cwd ]] - local w=$? + # w=0: writable + # w=1: not writable + # w=2: does not exist + (( !_POWERLEVEL9K_DIR_SHOW_WRITABLE )) || [[ -w $_p9k__cwd ]] + local -i w=$? + (( w && _POWERLEVEL9K_DIR_SHOW_WRITABLE > 2 )) && [[ ! -e $_p9k__cwd ]] && w=2 if ! _p9k_cache_ephemeral_get $0 $_p9k__cwd $p $w $fake_first "${parts[@]}"; then local state=$0 local icon='' @@ -1914,9 +1918,11 @@ prompt_dir() { break fi done - if (( ! w )); then + if (( w )); then if (( _POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 )); then state=${0}_NOT_WRITABLE + elif (( w == 2 )); then + state+=_NON_EXISTENT else state+=_NOT_WRITABLE fi @@ -2031,6 +2037,7 @@ prompt_dir() { (( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k__d::=0}+}$content"}" || _p9k__ret= _p9k_cache_ephemeral_set "$state" "$icon" "$expand" "$content" $_p9k__ret + typeset -p state >>/tmp/log fi if (( _p9k__cache_val[3] )); then @@ -7068,6 +7075,7 @@ _p9k_init_params() { case $_POWERLEVEL9K_DIR_SHOW_WRITABLE in true) _POWERLEVEL9K_DIR_SHOW_WRITABLE=1;; v2) _POWERLEVEL9K_DIR_SHOW_WRITABLE=2;; + v3) _POWERLEVEL9K_DIR_SHOW_WRITABLE=3;; *) _POWERLEVEL9K_DIR_SHOW_WRITABLE=0;; esac typeset -gi _POWERLEVEL9K_DIR_SHOW_WRITABLE @@ -7937,7 +7945,7 @@ _p9k_must_init() { [[ $sig == $_p9k__param_sig ]] && return 1 _p9k_deinit fi - _p9k__param_pat=$'v112\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' + _p9k__param_pat=$'v113\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1' -- cgit v1.2.3