diff options
author | Daniel Tam <grilled_chips@hotmail.com> | 2018-02-03 12:14:52 +0300 |
---|---|---|
committer | Daniel Tam <grilled_chips@hotmail.com> | 2018-02-03 12:14:52 +0300 |
commit | 04850df7504326e06588bbbde4213137c9360e88 (patch) | |
tree | a1857be192b40a5693e90a426dc7833716f14d10 /powerlevel9k.zsh-theme | |
parent | fd3d2343547b07d74cb102dd843f8a54d9e0b79f (diff) |
Add absolute truncation option to dir segment
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c32ccd48..4224075e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -728,6 +728,13 @@ prompt_dir() { set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$(echo $current_path | rev | cut -c 1-$POWERLEVEL9K_SHORTEN_DIR_LENGTH | rev | cat <(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) -) + fi + # Alternative implementation + #current_path="%$POWERLEVEL9K_SHORTEN_DIR_LENGTH<$POWERLEVEL9K_SHORTEN_DELIMITER<%~%<<" + ;; truncate_middle) current_path=$(echo "$current_path" | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") ;; |