1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-18 13:41:56 +00:00

add d(delimiter length) for every strategy

This commit is contained in:
Syphdias 2019-05-27 15:00:18 +02:00
parent 837bb94aa1
commit 2209c2c990
No known key found for this signature in database
GPG key ID: 6F62E6FB3E67F92D

View file

@ -767,13 +767,14 @@ prompt_dir() {
local -a parts=("${(s:/:)p}") local -a parts=("${(s:/:)p}")
fi fi
local -i fake_first=0 shortenlen local -i fake_first=0
local delim=${POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'} local delim=${POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
local shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1} local -i shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1}
local -i d=${POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:-$#POWERLEVEL9K_SHORTEN_DELIMITER}
case $POWERLEVEL9K_SHORTEN_STRATEGY in case $POWERLEVEL9K_SHORTEN_STRATEGY in
truncate_absolute|truncate_absolute_chars) truncate_absolute|truncate_absolute_chars)
if (( shortenlen > 0 && $#p > shortenlen + 1 )); then if (( shortenlen > 0 && $#p > shortenlen + d )); then
local -i n=shortenlen local -i n=shortenlen
local -i i=$#parts local -i i=$#parts
while true; do while true; do
@ -814,7 +815,7 @@ prompt_dir() {
[[ $POWERLEVEL9K_SHORTEN_STRATEGY == truncate_middle ]] && suf=pref [[ $POWERLEVEL9K_SHORTEN_STRATEGY == truncate_middle ]] && suf=pref
for (( ; i < $#parts; ++i )); do for (( ; i < $#parts; ++i )); do
local dir=$parts[i] local dir=$parts[i]
if (( $#dir > pref + suf + 1 )); then if (( $#dir > pref + suf + d )); then
dir[pref+1,-suf-1]=$'\0' dir[pref+1,-suf-1]=$'\0'
parts[i]=$dir parts[i]=$dir
fi fi
@ -835,11 +836,10 @@ prompt_dir() {
fi fi
;; ;;
truncate_to_unique) truncate_to_unique)
local -i i=2 n=1 d=0 local -i i=2 n=1
[[ $p == /* ]] && (( ++i )) [[ $p == /* ]] && (( ++i ))
delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'} delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'}
shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} shortenlen=${POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1}
d=${POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:-$#POWERLEVEL9K_SHORTEN_DELIMITER}
(( shortenlen >= 0 )) && n=shortenlen (( shortenlen >= 0 )) && n=shortenlen
local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-'(.bzr|CVS|.git|.hg|.svn|.citc)'} local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-'(.bzr|CVS|.git|.hg|.svn|.citc)'}
local parent="${PWD%/${(pj./.)parts[i,-1]}}" local parent="${PWD%/${(pj./.)parts[i,-1]}}"