aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-10-28 19:06:05 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-10-28 19:06:05 +0300
commitc6c0ee59d789a31ed168705592864c55622d4190 (patch)
tree602b906318d2f3bb131f11fc823261ed7edc5ac8 /internal/p10k.zsh
parentdaee88bc01234eabfe05dd43a10de1da61113c43 (diff)
speed up dotnet
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh44
1 files changed, 37 insertions, 7 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index daa89870..dacd7138 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1990,12 +1990,41 @@ prompt_dotnet_version() {
(( $+commands[dotnet] )) || return
if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then
- local dir=$_p9k_pwd
- while true; do
- [[ $dir == / ]] && return
- [[ -n $dir/(project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln)(#qN^/) ]] && break
- dir=${dir:h}
- done
+ case $_p9k_pwd in
+ ~|/) return;;
+ ~/*)
+ local parent=~/
+ local parts=(${(s./.)_p9k_pwd#$parent})
+ ;;
+ *)
+ local parent=/
+ local parts=(${(s./.)_p9k_pwd})
+ ;;
+ esac
+ local MATCH
+ local dirs=(${(@)${:-{1..$#parts}}/(#m)*/$parent${(pj./.)parts[i,$MATCH]}})
+ local mtimes=()
+ zstat -A mtimes +mtime -- $dirs 2>/dev/null || mtimes=()
+ local key="${(pj.:.)mtimes}"
+ if ! _p9k_cache_ephemeral_get $0 $_p9k_pwd || [[ $key != $_p9k_cache_val[1] ]] ; then
+ echo big miss
+ local -i i found
+ for i in {1..$#dirs}; do
+ local dir=$dirs[i] mtime=$mtimes[i]
+ local pair=$_p9k__dotnet_cache[$dir]
+ if [[ $pair == ${mtime:-x}:* ]]; then
+ (( $pair[-1] )) && found=1
+ else
+ echo miss $dir
+ [[ -z $dir/(project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln)(#qN^/) ]]
+ local -i has=$?
+ (( has )) && found=1
+ [[ -n $mtime ]] && _p9k__dotnet_cache[$dir]="$mtime:$has"
+ fi
+ done
+ [[ -n $key ]] && _p9k_cache_ephemeral_set "$key" $found
+ fi
+ (( _p9k_cache_val[2] )) || return
fi
_p9k_cached_cmd_stdout dotnet --version || return
@@ -4349,6 +4378,7 @@ _p9k_init_vars() {
typeset -g _p9k_uname_m
typeset -gi _p9k__transient_rprompt_active
+ typeset -gA _p9k__dotnet_cache
typeset -g P9K_VISUAL_IDENTIFIER
typeset -g P9K_CONTENT
@@ -4977,7 +5007,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit
fi
- _p9k__param_pat=$'v0\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
+ _p9k__param_pat=$'v1\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'