diff options
author | romkatv <roman.perepelitsa@gmail.com> | 2019-06-01 08:27:23 +0300 |
---|---|---|
committer | romkatv <roman.perepelitsa@gmail.com> | 2019-06-01 08:27:23 +0300 |
commit | 68e79d3cb5602f02f2d6a28afe6f14761395cead (patch) | |
tree | 00725eb9f06372b8fb004c86af06cf609b0b7362 /powerlevel9k.zsh-theme | |
parent | 4def4452dfad4401090f135adac88d18b0589251 (diff) |
speed up truncate_with_package_name
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1268acf7..50a8b943 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -819,9 +819,15 @@ prompt_dir() { for (( ; i > 0; --i )); do local pkg_file='' for pkg_file in $dir/${~pat}(N); do - local pkg_name='' - pkg_name=$(command jq -j '.name' <$pkg_file) && [[ -n $pkg_name ]] || return - parts[1,i]=($pkg_name) + local -H stat=() + zstat -H stat -- $pkg_file 2>/dev/null || return + if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then + local pkg_name='' + pkg_name=$(command jq -j '.name' <$pkg_file 2>/dev/null) || pkg_name='' + _p9k_cache_set "$pkg_name" + fi + [[ -n $_P9K_CACHE_VAL[1] ]] || return + parts[1,i]=($_P9K_CACHE_VAL[1]) fake_first=1 return done |