mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-25 21:40:08 +00:00
try POWERLEVEL9K_DIR_PACKAGE_FILES patterns in order and skip files without "name" in them; fixes #190
This commit is contained in:
parent
9e505d3dc1
commit
ce532fea3e
1 changed files with 21 additions and 15 deletions
|
@ -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…
Reference in a new issue