diff options
author | Syphdias <syphdias+git@gmail.com> | 2019-05-25 22:05:42 +0300 |
---|---|---|
committer | Syphdias <syphdias+git@gmail.com> | 2019-05-25 22:05:42 +0300 |
commit | 6c61fb5c20c015b9ec8d26946fda265c3904f3f7 (patch) | |
tree | 7f80c7d6525c1e2ac6396c65a76c3cb14616cc1b /powerlevel9k.zsh-theme | |
parent | bbebf516abeb55c96ad6e83478581b1230df6ec2 (diff) |
fixes multiple truncate_to_unique inconsistencies
1. also truncate first dir
2. length of `POWERLEVEL9K_SHORTEN_DELIMITER` is now taken into account
3. set `POWERLEVEL9K_SHORTEN_DIR_LENGTH=0` to truncate even the last dir
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a34db566..388141f9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -836,8 +836,8 @@ prompt_dir() { ;; truncate_to_unique) local -i i=2 n=1 - [[ $p == /* ]] && (( ++i )) - (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 )) && n=POWERLEVEL9K_SHORTEN_DIR_LENGTH + delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'} + (( POWERLEVEL9K_SHORTEN_DIR_LENGTH >= 0 )) && n=POWERLEVEL9K_SHORTEN_DIR_LENGTH local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-'(.bzr|CVS|.git|.hg|.svn|.citc)'} local parent="${PWD%/${(pj./.)parts[i,-1]}}" for (( ; i <= $#parts - n; ++i )); do @@ -850,14 +850,13 @@ prompt_dir() { fi fi local -i j=1 - for (( ; j < $#dir; ++j )); do + for (( ; j + $#delim < $#dir; ++j )); do local -a matching=($parent/$dir[1,j]*/(N)) (( $#matching == 1 )) && break done - (( j == $#dir )) || parts[i]=$dir[1,j]$'\0' + (( j + $#delim >= $#dir )) || parts[i]=$dir[1,j]$'\0' parent+=/$dir done - delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'} ;; truncate_with_folder_marker) local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-.shorten_folder_marker} |