dir: add _NON_EXISTENT similarly to _NON_WRITABLE (requires POWERLEVEL9K_DIR_SHOW_WRITABLE=v3)

See #1160.
pull/1161/head
Roman Perepelitsa 4 years ago
parent 1d99a0bac3
commit 439ce3ed4e

@ -274,12 +274,12 @@
# the full directory that was used in previous commands. # the full directory that was used in previous commands.
typeset -g POWERLEVEL9K_DIR_HYPERLINK=false typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
# Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
# POWERLEVEL9K_DIR_CLASSES below. # and POWERLEVEL9K_DIR_CLASSES below.
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
# The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is # The default icon shown next to non-writable and non-existent directories when
# set to v2. # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='⭐' # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@ -292,8 +292,8 @@
# #
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
# #
# If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable, # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
# its class gets suffix _NOT_WRITABLE. # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
# #
# For example, given these settings: # For example, given these settings:
# #
@ -302,8 +302,9 @@
# '~(|/*)' HOME '' # '~(|/*)' HOME ''
# '*' DEFAULT '') # '*' DEFAULT '')
# #
# Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
# WORK or WORK_NOT_WRITABLE. # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
# WORK_NON_EXISTENT.
# #
# Simply assigning classes to directories doesn't have any visible effects. It merely gives you an # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes. # option to define custom colors and icons for different directory classes.
@ -320,6 +321,12 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39
# #
# # Styling for WORK_NON_EXISTENT.
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39
#
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND. # back to POWERLEVEL9K_DIR_FOREGROUND.

@ -272,8 +272,12 @@
# POWERLEVEL9K_DIR_CLASSES below. # POWERLEVEL9K_DIR_CLASSES below.
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2
# The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
# set to v2. # and POWERLEVEL9K_DIR_CLASSES below.
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
# The default icon shown next to non-writable and non-existent directories when
# POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='⭐' # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@ -286,8 +290,8 @@
# #
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
# #
# If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable, # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
# its class gets suffix _NOT_WRITABLE. # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
# #
# For example, given these settings: # For example, given these settings:
# #
@ -296,8 +300,9 @@
# '~(|/*)' HOME '' # '~(|/*)' HOME ''
# '*' DEFAULT '') # '*' DEFAULT '')
# #
# Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
# WORK or WORK_NOT_WRITABLE. # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
# WORK_NON_EXISTENT.
# #
# Simply assigning classes to directories doesn't have any visible effects. It merely gives you an # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes. # option to define custom colors and icons for different directory classes.
@ -312,7 +317,13 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=4 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=4 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4#
#
# Styling for WORK_NON_EXISTENT.
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=4
# #
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls

@ -268,12 +268,12 @@
# the full directory that was used in previous commands. # the full directory that was used in previous commands.
typeset -g POWERLEVEL9K_DIR_HYPERLINK=false typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
# Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
# POWERLEVEL9K_DIR_CLASSES below. # and POWERLEVEL9K_DIR_CLASSES below.
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
# The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is # The default icon shown next to non-writable and non-existent directories when
# set to v2. # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='⭐' # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@ -286,8 +286,8 @@
# #
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
# #
# If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable, # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
# its class gets suffix _NOT_WRITABLE. # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
# #
# For example, given these settings: # For example, given these settings:
# #
@ -296,8 +296,9 @@
# '~(|/*)' HOME '' # '~(|/*)' HOME ''
# '*' DEFAULT '') # '*' DEFAULT '')
# #
# Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
# WORK or WORK_NOT_WRITABLE. # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
# WORK_NON_EXISTENT.
# #
# Simply assigning classes to directories doesn't have any visible effects. It merely gives you an # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes. # option to define custom colors and icons for different directory classes.
@ -314,6 +315,12 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39
# #
# # Styling for WORK_NON_EXISTENT.
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39
#
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND. # back to POWERLEVEL9K_DIR_FOREGROUND.

@ -274,12 +274,12 @@
# the full directory that was used in previous commands. # the full directory that was used in previous commands.
typeset -g POWERLEVEL9K_DIR_HYPERLINK=false typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
# Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
# POWERLEVEL9K_DIR_CLASSES below. # and POWERLEVEL9K_DIR_CLASSES below.
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
# The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is # The default icon shown next to non-writable and non-existent directories when
# set to v2. # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='⭐' # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@ -292,8 +292,8 @@
# #
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
# #
# If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable, # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
# its class gets suffix _NOT_WRITABLE. # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
# #
# For example, given these settings: # For example, given these settings:
# #
@ -302,8 +302,9 @@
# '~(|/*)' HOME '' # '~(|/*)' HOME ''
# '*' DEFAULT '') # '*' DEFAULT '')
# #
# Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
# WORK or WORK_NOT_WRITABLE. # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
# WORK_NON_EXISTENT.
# #
# Simply assigning classes to directories doesn't have any visible effects. It merely gives you an # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes. # option to define custom colors and icons for different directory classes.
@ -322,6 +323,13 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=250 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=250
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=255 # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=255
# #
# # Styling for WORK_NON_EXISTENT.
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_BACKGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=254
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=250
# typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=255
#
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND. # back to POWERLEVEL9K_DIR_FOREGROUND.

@ -1901,8 +1901,12 @@ prompt_dir() {
;; ;;
esac esac
[[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE != 0 && ! -w $_p9k__cwd ]] # w=0: writable
local w=$? # 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 if ! _p9k_cache_ephemeral_get $0 $_p9k__cwd $p $w $fake_first "${parts[@]}"; then
local state=$0 local state=$0
local icon='' local icon=''
@ -1914,9 +1918,11 @@ prompt_dir() {
break break
fi fi
done done
if (( ! w )); then if (( w )); then
if (( _POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 )); then if (( _POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 )); then
state=${0}_NOT_WRITABLE state=${0}_NOT_WRITABLE
elif (( w == 2 )); then
state+=_NON_EXISTENT
else else
state+=_NOT_WRITABLE state+=_NOT_WRITABLE
fi fi
@ -2031,6 +2037,7 @@ prompt_dir() {
(( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k__d::=0}+}$content"}" || _p9k__ret= (( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k__d::=0}+}$content"}" || _p9k__ret=
_p9k_cache_ephemeral_set "$state" "$icon" "$expand" "$content" $_p9k__ret _p9k_cache_ephemeral_set "$state" "$icon" "$expand" "$content" $_p9k__ret
typeset -p state >>/tmp/log
fi fi
if (( _p9k__cache_val[3] )); then if (( _p9k__cache_val[3] )); then
@ -7068,6 +7075,7 @@ _p9k_init_params() {
case $_POWERLEVEL9K_DIR_SHOW_WRITABLE in case $_POWERLEVEL9K_DIR_SHOW_WRITABLE in
true) _POWERLEVEL9K_DIR_SHOW_WRITABLE=1;; true) _POWERLEVEL9K_DIR_SHOW_WRITABLE=1;;
v2) _POWERLEVEL9K_DIR_SHOW_WRITABLE=2;; v2) _POWERLEVEL9K_DIR_SHOW_WRITABLE=2;;
v3) _POWERLEVEL9K_DIR_SHOW_WRITABLE=3;;
*) _POWERLEVEL9K_DIR_SHOW_WRITABLE=0;; *) _POWERLEVEL9K_DIR_SHOW_WRITABLE=0;;
esac esac
typeset -gi _POWERLEVEL9K_DIR_SHOW_WRITABLE typeset -gi _POWERLEVEL9K_DIR_SHOW_WRITABLE
@ -7937,7 +7945,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi 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+=$'${#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_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' _p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'

Loading…
Cancel
Save