Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the icon and the states in the dir segment to be easy configurable by users. #98

Merged
merged 2 commits into from
Jul 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions internal/p10k.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ typeset -gi _P9K_I
typeset -g _P9K_BG
typeset -g _P9K_F

typeset -gA ICON_ASSOC=(
"/etc|/etc/*" ETC_ICON
"${HOME}" HOME_ICON
"${HOME}/*" HOME_SUB_ICON
)
typeset -gA STATE_ASSOC=(
"/etc|/etc/*" ETC
"${HOME}" HOME
"${HOME}/*" HOME_SUBFOLDER
)
# Specifies the maximum number of elements in the cache. When the cache grows over this limit,
# it gets cleared. This is meant to avoid memory leaks when a rogue prompt is filling the cache
# with data.
Expand Down Expand Up @@ -868,14 +878,9 @@ prompt_dir() {
state=NOT_WRITABLE
icon=LOCK_ICON
else
case $PWD in
/etc|/etc/*) state=ETC; icon=ETC_ICON;;
~) state=HOME; icon=HOME_ICON;;
~/*) state=HOME_SUBFOLDER; icon=HOME_SUB_ICON;;
*) state=DEFAULT; icon=FOLDER_ICON;;
esac
icon=${ICON_ASSOC[(k)$PWD]:-DEFAULT}
state=${STATE_ASSOC[(k)$PWD]:-DEFAULT}
fi

local style=%b
_p9k_color blue $0_$state BACKGROUND
_p9k_background $_P9K_RETVAL
Expand Down