summaryrefslogtreecommitdiff
path: root/functions/utilities.zsh
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-10-27 17:59:55 +0300
committerGitHub <noreply@github.com>2016-10-27 17:59:55 +0300
commitfd9c998f02966229d0dfa576d0056bae21267a2a (patch)
tree25f631fa68ce5bf68627cb9ab697eb4a41395cbe /functions/utilities.zsh
parent3c92cf9748cff350a14cc8f42eda439c5fe01baa (diff)
parent8d7a4e462ae93169be59c07a06c269fc254aa96b (diff)
Merge pull request #333 from eviltak/dir-truncate-right-with-delim-len
Consider delimiter length while right truncating directories
Diffstat (limited to 'functions/utilities.zsh')
-rw-r--r--functions/utilities.zsh4
1 files changed, 3 insertions, 1 deletions
diff --git a/functions/utilities.zsh b/functions/utilities.zsh
index c9bd2e46..f27c7f99 100644
--- a/functions/utilities.zsh
+++ b/functions/utilities.zsh
@@ -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"
}