summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-05-19 16:53:09 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-05-19 16:53:09 +0300
commit1ba90abd4afc97a9a7916f7a85651008d53d9c81 (patch)
tree5ff0c1283be25a68faa4a0c3eb9b2bb5b73a876a /powerlevel9k.zsh-theme
parent3c5b52750e9eb3ac1bf6ad86959548f381d52c83 (diff)
truncate_to_unique: respect POWERLEVEL9K_SHORTEN_FOLDER_MARKER with default value of (.bzr|CVS|.git|.hg|.svn|.citc)
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme48
1 files changed, 29 insertions, 19 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 33e70df1..bf4c71a8 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -792,9 +792,6 @@ set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false
set_default POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER false
set_default POWERLEVEL9K_SHORTEN_STRATEGY ""
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND ""
-# This defines a pattern. It is expanded with the options set by `emulate zsh`.
-# This works pretty well: POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(.bzr|CVS|.git|.hg|.svn|.citc)"
-set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker"
set_default -i POWERLEVEL9K_SHORTEN_DIR_LENGTH -1
# Individual elements are patterns. They are expanded with the options set by `emulate zsh`.
set_default -a POWERLEVEL9K_DIR_PACKAGE_FILES package.json composer.json
@@ -895,33 +892,46 @@ prompt_dir() {
fi
;;
truncate_to_unique)
- local parent="${PWD%/${(pj./.)parts[2,-1]}}" dir=''
- local -i i=2
- for (( ; i < $#parts; ++i )); do
+ local -i i=2 n=1
+ [[ $p == /* ]] && (( ++i ))
+ (( 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
local dir=$parts[i]
+ if [[ -n $pat ]]; then
+ local -a matches=($parent/$dir/${~pat}(N))
+ if (( $#matches )); then
+ parent+=/$dir
+ continue
+ fi
+ fi
local -i j=1
for (( ; j < $#dir; ++j )); do
local -a matching=($parent/$dir[1,j]*/(N))
(( $#matching == 1 )) && break
done
- parent+=/$dir
(( j == $#dir )) || parts[i]=$dir[1,j]$'\0'
+ parent+=/$dir
done
delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'}
;;
truncate_with_folder_marker)
- local dir=$PWD
- local -a m=()
- local -i i=$(($#parts - 1))
- for (( ; i > 1; --i )); do
- dir=${dir:h}
- local -a matches=($dir/${~POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(N))
- (( $#matches )) && m+=$i
- done
- m+=1
- for (( i=1; i < $#m; ++i )); do
- (( m[i] - m[i+1] > 2 )) && parts[m[i+1]+1,m[i]-1]=($'\0')
- done
+ local pat=${POWERLEVEL9K_SHORTEN_FOLDER_MARKER-.shorten_folder_marker}
+ if [[ -n $pat ]]; then
+ local dir=$PWD
+ local -a m=()
+ local -i i=$(($#parts - 1))
+ for (( ; i > 1; --i )); do
+ dir=${dir:h}
+ local -a matches=($dir/${~pat}(N))
+ (( $#matches )) && m+=$i
+ done
+ m+=1
+ for (( i=1; i < $#m; ++i )); do
+ (( m[i] - m[i+1] > 2 )) && parts[m[i+1]+1,m[i]-1]=($'\0')
+ done
+ fi
;;
*)
if (( POWERLEVEL9K_SHORTEN_DIR_LENGTH > 0 )); then