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

Add absolute truncation option to dir segment

This commit is contained in:
Daniel Tam 2018-02-03 20:14:52 +11:00
parent fd3d234354
commit 04850df750
No known key found for this signature in database
GPG key ID: 28DC329F2B6F7A6B

View file

@ -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")
;;