|
|
|
@ -2053,6 +2053,59 @@ prompt_history() {
|
|
|
|
|
(( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prompt_package() {
|
|
|
|
|
unset P9K_PACKAGE_NAME P9K_PACKAGE_VERSION
|
|
|
|
|
_p9k_upglob package.json && return
|
|
|
|
|
|
|
|
|
|
local file=$_p9k__parent_dirs[$?]/package.json
|
|
|
|
|
if ! _p9k_cache_stat_get $0 $file; then
|
|
|
|
|
() {
|
|
|
|
|
local data field
|
|
|
|
|
local -A found
|
|
|
|
|
{ data="$(<$file)" || return } 2>/dev/null
|
|
|
|
|
data=${data##[[:space:]]#}
|
|
|
|
|
[[ $data == '{'* ]] || return
|
|
|
|
|
data[1]=
|
|
|
|
|
local -i depth=1
|
|
|
|
|
while true; do
|
|
|
|
|
data=${data##[[:space:]]#}
|
|
|
|
|
[[ -n $data ]] || return
|
|
|
|
|
case $data[1] in
|
|
|
|
|
'{'|'[') data[1]=; (( ++depth ));;
|
|
|
|
|
'}'|']') data[1]=; (( --depth > 0 )) || return;;
|
|
|
|
|
':') data[1]=;;
|
|
|
|
|
',') data[1]=; field=;;
|
|
|
|
|
[[:alnum:].]) data=${data##[[:alnum:].]#};;
|
|
|
|
|
'"')
|
|
|
|
|
local tail=${data##\"([^\"\\]|\\?)#}
|
|
|
|
|
[[ $tail == '"'* ]] || return
|
|
|
|
|
local s=${data:1:-$#tail}
|
|
|
|
|
data=${tail:1}
|
|
|
|
|
(( depth == 1 )) || continue
|
|
|
|
|
if [[ -z $field ]]; then
|
|
|
|
|
field=${s:-x}
|
|
|
|
|
elif [[ $field == (name|version) ]]; then
|
|
|
|
|
(( ! $+found[$field] )) || return
|
|
|
|
|
[[ -n $s ]] || return
|
|
|
|
|
print -v 'found[$field]' -- $s # this isn't quite right but close enough
|
|
|
|
|
(( $#found == 2 )) && break
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
*) return 1;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
_p9k_cache_stat_set 1 $found[name] $found[version]
|
|
|
|
|
return 0
|
|
|
|
|
} || _p9k_cache_stat_set 0
|
|
|
|
|
fi
|
|
|
|
|
(( _p9k__cache_val[1] )) || return
|
|
|
|
|
|
|
|
|
|
P9K_PACKAGE_NAME=$_p9k__cache_val[2]
|
|
|
|
|
P9K_PACKAGE_VERSION=$_p9k__cache_val[3]
|
|
|
|
|
local text="${${P9K_PACKAGE_NAME##*/}//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}"
|
|
|
|
|
_p9k_prompt_segment "$0" "cyan" "$_p9k_color1" PACKAGE_ICON 0 '' $text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
|
# Detection for virtualization (systemd based systems only)
|
|
|
|
|
prompt_detect_virt() {
|
|
|
|
@ -7442,7 +7495,7 @@ _p9k_must_init() {
|
|
|
|
|
[[ $sig == $_p9k__param_sig ]] && return 1
|
|
|
|
|
_p9k_deinit
|
|
|
|
|
fi
|
|
|
|
|
_p9k__param_pat=$'v70\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
|
|
|
|
_p9k__param_pat=$'v71\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\1'
|
|
|
|
|