diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-10-28 17:54:53 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-10-28 17:54:53 +0300 |
commit | daee88bc01234eabfe05dd43a10de1da61113c43 (patch) | |
tree | ea4256807a9dd524f738d9efd00f78e24324b7ff /internal/p10k.zsh | |
parent | 6914a23b4413f8e42642147e5a2c4211a0a4f2e1 (diff) |
don't stat unnecessary dirs
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r-- | internal/p10k.zsh | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 62b61283..daa89870 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1447,26 +1447,26 @@ prompt_dir() { truncate_to_unique) expand=1 delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-'*'} - local -i i=2 + shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} + (( shortenlen >= 0 )) || shortenlen=1 + local -i i=2 e=$(($#parts - shortenlen)) [[ $p[1] == / ]] && (( ++i )) local parent="${_p9k_pwd%/${(pj./.)parts[i,-1]}}" - if (( i <= $#parts )); then - local mtime=() - zstat -A mtime +mtime -- ${(@)${:-{$i..$#parts}}/(#b)(*)/$parent/${(pj./.)parts[i,$match[1]]}} 2>/dev/null || mtime=() + if (( i <= e )); then + local MATCH= mtime=() + zstat -A mtime +mtime -- ${(@)${:-{$i..$e}}/(#m)*/$parent/${(pj./.)parts[i,$MATCH]}} 2>/dev/null || mtime=() mtime="${(pj:\1:)mtime}" else local mtime='good' fi if ! _p9k_cache_ephemeral_get $0 "${parts[@]}" || [[ -z $mtime || $mtime != $_p9k_cache_val[1] ]] ; then _p9k_prompt_length $delim - local -i real_delim_len=_p9k_ret n=1 q=0 + local -i real_delim_len=_p9k_ret q=0 [[ -n $parts[i-1] ]] && parts[i-1]="\${(Q)\${:-${(qqq)${(q)parts[i-1]}}}}"$'\2' [[ $p[i,-1] == *["~!#\$^&*()\\\"'<>?{}[]"]* ]] && q=1 local -i d=${_POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH:--1} (( d >= 0 )) || d=real_delim_len - shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} - (( shortenlen >= 0 )) && n=shortenlen - for (( ; i <= $#parts - n; ++i )); do + for (( ; i <= $#parts - shortenlen; ++i )); do local dir=$parts[i] if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER && -n $parent/$dir/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then |