mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-17 10:10:07 +00:00
Consider delimiter length in dir truncate right
Truncating the path from the right now takes in account the delimiter length, so that directories with names shorter than truncated name + delimiter are displayed properly. For example, if SHORTEN_DIR_LENGTH is 4 and the delimiter is "..", "../tests/.." and "../custom/.." are not incorrectly "truncated" to "../test../.." and "../cust../..", both of which are longer or the same length as the original.
This commit is contained in:
parent
c4fdc8f708
commit
1edb74ba91
1 changed files with 3 additions and 1 deletions
|
@ -204,5 +204,7 @@ function segmentShouldBeJoined() {
|
|||
# Given a directory path, truncate it according to the settings for
|
||||
# `truncate_from_right`
|
||||
function truncatePathFromRight() {
|
||||
echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\//g"
|
||||
local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER}
|
||||
echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \
|
||||
"s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue