speed up truncate_to_unique

pull/145/head
romkatv 5 years ago
parent b7a8139e97
commit d81b4dbf68

@ -1138,16 +1138,25 @@ prompt_dir() {
truncate_to_unique)
expand=1
delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'}
_p9k_prompt_length $delim
local -i real_delim_len=_P9K_RETVAL i=2 n=1 q=0
local -i i=2
[[ $p[1] == / ]] && (( ++i ))
local parent="${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=()
mtime="${(pj:\1:)mtime}"
else
local mtime='good'
fi
if ! _p9k_cache_get $0 "${parts[@]}" || [[ -z $mtime || $mtime != $_P9K_CACHE_VAL[1] ]] ; then
_p9k_prompt_length $delim
local -i real_delim_len=_P9K_RETVAL n=1 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
local parent="${PWD%/${(pj./.)parts[i,-1]}}"
for (( ; i <= $#parts - n; ++i )); do
local dir=$parts[i]
if [[ -n $POWERLEVEL9K_SHORTEN_FOLDER_MARKER &&
@ -1179,6 +1188,9 @@ prompt_dir() {
(( q )) && parts[i]='${(Q)${:-'${(qqq)${(q)parts[i]}}'}}'
parts[i]+=$'\2'
done
_p9k_cache_set "$mtime" "${parts[@]}"
fi
parts=("${(@)_P9K_CACHE_VAL[2,-1]}")
;;
truncate_with_folder_marker)
if [[ -n $POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]]; then

Loading…
Cancel
Save