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

pull/198/head
romkatv 5 years ago
parent 9e505d3dc1
commit ce532fea3e

@ -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 pat= pkg_file=
for pat in $_POWERLEVEL9K_DIR_PACKAGE_FILES; do
for pkg_file in $markers; do
[[ $pkg_file == $dir/${~pat} ]] || continue
local -H stat=() local -H stat=()
zstat -H stat -- $pkg_file 2>/dev/null || return zstat -H stat -- $pkg_file 2>/dev/null || continue
if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then
local pkg_name='' local pkg_name=''
pkg_name="$(jq -j '.name' <$pkg_file 2>/dev/null)" || pkg_name='' pkg_name="$(jq -j '.name | select(. != null)' <$pkg_file 2>/dev/null)" || pkg_name=''
_p9k_cache_set "$pkg_name" _p9k_cache_set "$pkg_name"
fi fi
[[ -n $_p9k_cache_val[1] ]] || return [[ -n $_p9k_cache_val[1] ]] || continue
parts[1,i]=($_p9k_cache_val[1]) parts[1,i]=($_p9k_cache_val[1])
fake_first=1 fake_first=1
return return
done done
done
fi
dir=${dir:h} dir=${dir:h}
done done
} }

Loading…
Cancel
Save