Closed onaforeignshore closed 4 years ago
This is done. See config templates for documentation: https://github.com/romkatv/powerlevel10k/blob/459af1f2382ff53214bf9e4fc598b4e36fb8f8df/config/p10k-rainbow.zsh#L271-L323
Have you tried it? Does it do what you want?
It works to an extent. I did this...
typeset -g POWERLEVEL9K_DIR_CLASSES=(
'~' HOME 'home_icon '
'~/*' HOME_SUBFOLDER 'home_sub_icon '
'/private/etc(|/*)' ETC ' '
'*' DEFAULT 'default_icon '
)
typeset -g POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=27
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_BACKGROUND=55
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='etc_icon '
typeset -g POWERLEVEL9K_DIR_HOME_BACKGROUND=25
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND=26
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER_NOT_WRITABLE_BACKGROUND=55
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_BACKGROUND=88
This was the only way I got it to work the way I wanted it to
You can make configuration a bit simpler by setting icons within POWERLEVEL9K_DIR_CLASSES
to empty and specifying the background and icons for every state explicitly. It also help to list states in the same order in both lists (once POWERLEVEL9K_DIR_CLASSES
and then below).
typeset -g POWERLEVEL9K_DIR_CLASSES=(
'~' HOME ''
'~/*' HOME_SUBFOLDER ''
'/private/etc(|/*)' ETC ''
'*' DEFAULT ''
)
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_BACKGROUND=25
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='home_icon '
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_BACKGROUND=26
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='home_sub_icon '
typeset -g POWERLEVEL9K_DIR_ETC_BACKGROUND=25
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_BACKGROUND=55
typeset -g POWERLEVEL9K_DIR_ETC_VISUAL_IDENTIFIER_EXPANSION=' '
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='etc_icon '
typeset -g POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=27
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_BACKGROUND=88
typeset -g POWERLEVEL9K_DIR_DEFAULT{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='default_icon '
It's more verbose but easier to reason about. For example, your config doesn't specify POWERLEVEL9K_DIR_ETC_BACKGROUND
, so it falls back to POWERLEVEL9K_DIR_BACKGROUND
(this is an extension compared to p9k: POWERLEVEL9K_SEGMENT_STATE_BACKGROUND
falls back to POWERLEVEL9K_SEGMENT_BACKGROUND
and then to `POWERLEVEL9K_BACKGROUND
.) Similarly for POWERLEVEL9K_DIR_HOME_NOT_WRITABLE_BACKGROUND
-- you are unlikely to encounter this state but having it missing in the config can be confusing.
Is there anything that doesn't work as you like? Anything missing? Since I've implemented this feature solely on your request, I'd like to know whether it satisfies at least the original purpose.
Based on your comments, I did this:
typeset -g POWERLEVEL9K_DIR_FOREGROUND=252
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_BACKGROUND=25
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='homee)icon '
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_BACKGROUND=26
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='home_sub_icon '
typeset -g POWERLEVEL9K_DIR_ETC_BACKGROUND=27
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_BACKGROUND=55
typeset -g PO\WERLEVEL9K_DIR_ETC_{,NOT_WRITABLE_}VISUAL_IDENTIFIER_EXPANSION='etc_icon '
typeset -g POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=27
typeset -g POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='default_icon '
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_BACKGROUND=88
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='default_nw_icon '
I used the global scope FOREGROUND colour, because only the backgrounds change (rainbow prompt).
This works, if somewhat verbose, thank you.
Thanks for the confirmation.
I realize that it's verbose. I think it's more important that it's consistent. Configuration is done per class/state the same way it works in p9k. It's the same for built-in states and those defined by CLASSES
.
It's a bit unfortunate that POWERLEVEL9K_DIR_CLASSES
should have empty elements in it. This is the first CLASSES
parameter that I implemented and there was no VISUAL_IDENTIFIER_EXPANSION
back then. All other CLASSES
parameters are consistent and do only one job -- assign class/state based on the segment's content. Then configuration is done through the usual parameters supported by the respective segment.
I am having issues that the ETC
isn't changing colour or icon. They are getting default not writable state
Sorry about that. Please update powerlevel10k and try again.
Updated and still the same.
This is my config after making the recommended changes (ignore the icons that don't make sense here):
typeset -g POWERLEVEL9K_DIR_CLASSES=(
'~' HOME ''
'~/*' HOME_SUBFOLDER ''
'/private/etc(|/*)' ETC ''
'*' DEFAULT ''
)
typeset -g POWERLEVEL9K_DIR_FOREGROUND='#d0d0d0'
# typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_FOREGROUND='#d0d0d0'
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_BACKGROUND='#005faf'
typeset -g POWERLEVEL9K_DIR_HOME{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='h '
# typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_FOREGROUND='#d0d0d0'
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_BACKGROUND='#005fd7'
typeset -g POWERLEVEL9K_DIR_HOME_SUBFOLDER{,_NOT_WRITABLE}_VISUAL_IDENTIFIER_EXPANSION='hs '
# typeset -g POWERLEVEL9K_DIR_ETC{,_NOT_WRITABLE}_FOREGROUND='#d0d0d0'
typeset -g POWERLEVEL9K_DIR_ETC_BACKGROUND='#005fff'
typeset -g POWERLEVEL9K_DIR_ETC_NOT_WRITABLE_BACKGROUND='#5f00af'
typeset -g POWERLEVEL9K_DIR_ETC_{,NOT_WRITABLE_}VISUAL_IDENTIFIER_EXPANSION='etc '
# typeset -g POWERLEVEL9K_DIR_DEFAULT{,_NOT_WRITABLE}_FOREGROUND='#d0d0d0'
typeset -g POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='#005fff'
typeset -g POWERLEVEL9K_DIR_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='def '
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_BACKGROUND='#870000'
typeset -g POWERLEVEL9K_DIR_DEFAULT_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='nw '
Now it's getting embarrassing. Please update again.
Is your config really missing typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2
or did you just not post it?
It is set 91 comments before what I just posted
Then your config LGTM. Should work once you update powerlevel10k.
Now it is working again. Thank you for all of your efforts on this.
Is there a way to get custom colouring and icons for a folder that is not writable when
POWERLEVEL9K_DIR_SHOW_WRITABLE=true
?I want to override some of the read-only folders like
/etc