1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

try POWERLEVEL9K_DIR_PACKAGE_FILES patterns in order and skip files without "name" in them; fixes #190

This commit is contained in:
romkatv 2019-08-28 19:32:10 +02:00
parent 9e505d3dc1
commit ce532fea3e

View file

@ -1225,24 +1225,30 @@ prompt_dir() {
() { () {
[[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name &&
$+commands[jq] == 1 && $#_POWERLEVEL9K_DIR_PACKAGE_FILES > 0 ]] || return $+commands[jq] == 1 && $#_POWERLEVEL9K_DIR_PACKAGE_FILES > 0 ]] || return
local pat="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})" local pats="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})"
local -i i=$#parts local -i i=$#parts
local dir=$_p9k_pwd local dir=$_p9k_pwd
for (( ; i > 0; --i )); do for (( ; i > 0; --i )); do
local pkg_file='' local markers=($dir/${~pats}(N))
for pkg_file in $dir/${~pat}(N); do if (( $#markers )); then
local -H stat=() local pat= pkg_file=
zstat -H stat -- $pkg_file 2>/dev/null || return for pat in $_POWERLEVEL9K_DIR_PACKAGE_FILES; do
if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then for pkg_file in $markers; do
local pkg_name='' [[ $pkg_file == $dir/${~pat} ]] || continue
pkg_name="$(jq -j '.name' <$pkg_file 2>/dev/null)" || pkg_name='' local -H stat=()
_p9k_cache_set "$pkg_name" zstat -H stat -- $pkg_file 2>/dev/null || continue
fi if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then
[[ -n $_p9k_cache_val[1] ]] || return local pkg_name=''
parts[1,i]=($_p9k_cache_val[1]) pkg_name="$(jq -j '.name | select(. != null)' <$pkg_file 2>/dev/null)" || pkg_name=''
fake_first=1 _p9k_cache_set "$pkg_name"
return fi
done [[ -n $_p9k_cache_val[1] ]] || continue
parts[1,i]=($_p9k_cache_val[1])
fake_first=1
return
done
done
fi
dir=${dir:h} dir=${dir:h}
done done
} }