aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorSyphdias <syphdias+git@gmail.com>2019-05-27 00:37:39 +0300
committerSyphdias <syphdias+git@gmail.com>2019-05-27 00:37:39 +0300
commitbead0ec05e18e6d27527c7cd29aa53cb6fbd2ce9 (patch)
treebaa534e440815405f44f4618592c2f0c0fdebe33 /powerlevel9k.zsh-theme
parentc5816238014d9ec92dc6d0f50014aa82a0af6a29 (diff)
add truncate_to_unique specific SHORTEN_DIR_LENGTH default
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme27
1 files changed, 14 insertions, 13 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index ee5b6564..db828b43 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -735,7 +735,6 @@ set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false
set_default POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER false
set_default POWERLEVEL9K_SHORTEN_STRATEGY ""
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND ""
-set_default -i POWERLEVEL9K_SHORTEN_DIR_LENGTH -1
# Individual elements are patterns. They are expanded with the options set by `emulate zsh`.
set_default -a POWERLEVEL9K_DIR_PACKAGE_FILES package.json composer.json
@@ -768,13 +767,14 @@ prompt_dir() {
local -a parts=("${(s:/:)p}")
fi
- local -i fake_first=0
+ local -i fake_first=0 shortenlen
local delim=${POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
+ local shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1}
case $POWERLEVEL9K_SHORTEN_STRATEGY in
truncate_absolute|truncate_absolute_chars)
- if (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 && $#p > POWERLEVEL9K_SHORTEN_DIR_LENGTH + 1 )); then
- local -i n=POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ if (( shortenlen > 0 && $#p > shortenlen + 1 )); then
+ local -i n=shortenlen
local -i i=$#parts
while true; do
local dir=$parts[i]
@@ -809,8 +809,8 @@ prompt_dir() {
dir=${dir:h}
done
}
- if (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 )); then
- local -i pref=$POWERLEVEL9K_SHORTEN_DIR_LENGTH suf=0 i=2
+ if (( shortenlen > 0 )); then
+ local -i pref=$shortenlen suf=0 i=2
[[ $POWERLEVEL9K_SHORTEN_STRATEGY == truncate_middle ]] && suf=pref
for (( ; i < $#parts; ++i )); do
local dir=$parts[i]
@@ -826,10 +826,10 @@ prompt_dir() {
parts[1,-2]=()
;;
truncate_to_first_and_last)
- if (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 )); then
- local -i i=$(( POWERLEVEL9K_SHORTEN_DIR_LENGTH + 1 ))
+ if (( shortenlen > 0 )); then
+ local -i i=$(( shortenlen + 1 ))
[[ $p == /* ]] && (( ++i ))
- for (( ; i <= $#parts - POWERLEVEL9K_SHORTEN_DIR_LENGTH; ++i )); do
+ for (( ; i <= $#parts - shortenlen; ++i )); do
parts[i]=$'\0'
done
fi
@@ -837,8 +837,9 @@ prompt_dir() {
truncate_to_unique)
local -i i=2 n=1 d=0
delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'}
+ shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1}
d=${POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:-$#POWERLEVEL9K_SHORTEN_DELIMITER}
- (( POWERLEVEL9K_SHORTEN_DIR_LENGTH >= 0 )) && n=POWERLEVEL9K_SHORTEN_DIR_LENGTH
+ (( shortenlen >= 0 )) && n=shortenlen
local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-'(.bzr|CVS|.git|.hg|.svn|.citc)'}
local parent="${PWD%/${(pj./.)parts[i,-1]}}"
for (( ; i <= $#parts - n; ++i )); do
@@ -877,11 +878,11 @@ prompt_dir() {
fi
;;
*)
- if (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 )); then
+ if (( shortenlen > 0 )); then
local -i len=$#parts
[[ -z $parts[1] ]] && (( --len ))
- if (( len > POWERLEVEL9K_SHORTEN_DIR_LENGTH )); then
- parts[1,-POWERLEVEL9K_SHORTEN_DIR_LENGTH-1]=($'\0')
+ if (( len > shortenlen )); then
+ parts[1,-shortenlen-1]=($'\0')
fi
fi
;;