mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 12:20:07 +00:00
presume that node --version
may depend on package.json (#1388)
This commit is contained in:
parent
a49f90d3ba
commit
717573d845
1 changed files with 24 additions and 17 deletions
|
@ -1096,7 +1096,7 @@ function _p9k_python_version() {
|
||||||
fi
|
fi
|
||||||
;& # fall through
|
;& # fall through
|
||||||
*)
|
*)
|
||||||
_p9k_cached_cmd 1 python --version || return
|
_p9k_cached_cmd 1 '' python --version || return
|
||||||
[[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1]
|
[[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1]
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -2129,7 +2129,7 @@ _p9k_prompt_docker_machine_init() {
|
||||||
################################################################
|
################################################################
|
||||||
# GO prompt
|
# GO prompt
|
||||||
prompt_go_version() {
|
prompt_go_version() {
|
||||||
_p9k_cached_cmd 0 go version || return
|
_p9k_cached_cmd 0 '' go version || return
|
||||||
[[ $_p9k__ret == (#b)*go([[:digit:].]##)* ]] || return
|
[[ $_p9k__ret == (#b)*go([[:digit:].]##)* ]] || return
|
||||||
local v=$match[1]
|
local v=$match[1]
|
||||||
if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then
|
if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then
|
||||||
|
@ -2354,18 +2354,20 @@ _p9k_prompt_load_sync() {
|
||||||
_p9k_worker_reply $REPLY
|
_p9k_worker_reply $REPLY
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: _p9k_cached_cmd <0|1> <cmd> [args...]
|
# Usage: _p9k_cached_cmd <0|1> <dep> <cmd> [args...]
|
||||||
#
|
#
|
||||||
# The first argument says whether to capture stderr (1) or ignore it (0).
|
# The first argument says whether to capture stderr (1) or ignore it (0).
|
||||||
|
# The second argument can be empty or a file. If it's a file, the
|
||||||
|
# output of the command is presumed to potentially depend on it.
|
||||||
function _p9k_cached_cmd() {
|
function _p9k_cached_cmd() {
|
||||||
local cmd=$commands[$2]
|
local cmd=$commands[$3]
|
||||||
[[ -n $cmd ]] || return
|
[[ -n $cmd ]] || return
|
||||||
if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then
|
if ! _p9k_cache_stat_get $0" ${(q)*}" $2 $cmd; then
|
||||||
local out
|
local out
|
||||||
if (( $1 )); then
|
if (( $1 )); then
|
||||||
out="$($cmd "${@:3}" 2>&1)"
|
out="$($cmd "${@:4}" 2>&1)"
|
||||||
else
|
else
|
||||||
out="$($cmd "${@:3}" 2>/dev/null)"
|
out="$($cmd "${@:4}" 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
_p9k_cache_stat_set $(( ! $? )) "$out"
|
_p9k_cache_stat_set $(( ! $? )) "$out"
|
||||||
fi
|
fi
|
||||||
|
@ -2376,10 +2378,15 @@ function _p9k_cached_cmd() {
|
||||||
################################################################
|
################################################################
|
||||||
# Segment to diplay Node version
|
# Segment to diplay Node version
|
||||||
prompt_node_version() {
|
prompt_node_version() {
|
||||||
if (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )); then
|
_p9k_upglob package.json
|
||||||
_p9k_upglob package.json && return
|
local -i idx=$?
|
||||||
|
if (( idx )); then
|
||||||
|
_p9k_cached_cmd 0 $_p9k__parent_dirs[idx]/package.json node --version || return
|
||||||
|
else
|
||||||
|
(( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )) && return
|
||||||
|
_p9k_cached_cmd 0 '' node --version || return
|
||||||
fi
|
fi
|
||||||
_p9k_cached_cmd 0 node --version && [[ $_p9k__ret == v?* ]] || return
|
[[ $_p9k__ret == v?* ]] || return
|
||||||
_p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${_p9k__ret#v}"
|
_p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${_p9k__ret#v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2473,10 +2480,10 @@ _p9k_nvm_ls_current() {
|
||||||
|
|
||||||
local nvm_dir=${NVM_DIR:A}
|
local nvm_dir=${NVM_DIR:A}
|
||||||
if [[ -n $nvm_dir && $node_path == $nvm_dir/versions/io.js/* ]]; then
|
if [[ -n $nvm_dir && $node_path == $nvm_dir/versions/io.js/* ]]; then
|
||||||
_p9k_cached_cmd 0 iojs --version || return
|
_p9k_cached_cmd 0 '' iojs --version || return
|
||||||
_p9k__ret=iojs-v${_p9k__ret#v}
|
_p9k__ret=iojs-v${_p9k__ret#v}
|
||||||
elif [[ -n $nvm_dir && $node_path == $nvm_dir/* ]]; then
|
elif [[ -n $nvm_dir && $node_path == $nvm_dir/* ]]; then
|
||||||
_p9k_cached_cmd 0 node --version || return
|
_p9k_cached_cmd 0 '' node --version || return
|
||||||
_p9k__ret=v${_p9k__ret#v}
|
_p9k__ret=v${_p9k__ret#v}
|
||||||
else
|
else
|
||||||
_p9k__ret=system
|
_p9k__ret=system
|
||||||
|
@ -2501,7 +2508,7 @@ _p9k_prompt_nvm_init() {
|
||||||
# Segment to display NodeEnv
|
# Segment to display NodeEnv
|
||||||
prompt_nodeenv() {
|
prompt_nodeenv() {
|
||||||
local msg
|
local msg
|
||||||
if (( _POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION )) && _p9k_cached_cmd 0 node --version; then
|
if (( _POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION )) && _p9k_cached_cmd 0 '' node --version; then
|
||||||
msg="${_p9k__ret//\%/%%} "
|
msg="${_p9k__ret//\%/%%} "
|
||||||
fi
|
fi
|
||||||
msg+="$_POWERLEVEL9K_NODEENV_LEFT_DELIMITER${${NODE_VIRTUAL_ENV:t}//\%/%%}$_POWERLEVEL9K_NODEENV_RIGHT_DELIMITER"
|
msg+="$_POWERLEVEL9K_NODEENV_LEFT_DELIMITER${${NODE_VIRTUAL_ENV:t}//\%/%%}$_POWERLEVEL9K_NODEENV_RIGHT_DELIMITER"
|
||||||
|
@ -2589,7 +2596,7 @@ prompt_dotnet_version() {
|
||||||
if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then
|
if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then
|
||||||
_p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' && return
|
_p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' && return
|
||||||
fi
|
fi
|
||||||
_p9k_cached_cmd 0 dotnet --version || return
|
_p9k_cached_cmd 0 '' dotnet --version || return
|
||||||
_p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k__ret"
|
_p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k__ret"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2613,7 +2620,7 @@ prompt_php_version() {
|
||||||
if (( _POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY )); then
|
if (( _POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY )); then
|
||||||
_p9k_upglob 'composer.json|*.php' && return
|
_p9k_upglob 'composer.json|*.php' && return
|
||||||
fi
|
fi
|
||||||
_p9k_cached_cmd 0 php --version || return
|
_p9k_cached_cmd 0 '' php --version || return
|
||||||
[[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return
|
[[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return
|
||||||
local v=$match[2]
|
local v=$match[2]
|
||||||
_p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}"
|
_p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}"
|
||||||
|
@ -4362,7 +4369,7 @@ _p9k_prompt_openfoam_init() {
|
||||||
################################################################
|
################################################################
|
||||||
# Segment to display Swift version
|
# Segment to display Swift version
|
||||||
prompt_swift_version() {
|
prompt_swift_version() {
|
||||||
_p9k_cached_cmd 0 swift --version || return
|
_p9k_cached_cmd 0 '' swift --version || return
|
||||||
[[ $_p9k__ret == (#b)[^[:digit:]]#([[:digit:].]##)* ]] || return
|
[[ $_p9k__ret == (#b)[^[:digit:]]#([[:digit:].]##)* ]] || return
|
||||||
_p9k_prompt_segment "$0" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}"
|
_p9k_prompt_segment "$0" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}"
|
||||||
}
|
}
|
||||||
|
@ -8094,7 +8101,7 @@ _p9k_must_init() {
|
||||||
[[ $sig == $_p9k__param_sig ]] && return 1
|
[[ $sig == $_p9k__param_sig ]] && return 1
|
||||||
_p9k_deinit
|
_p9k_deinit
|
||||||
fi
|
fi
|
||||||
_p9k__param_pat=$'v122\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
|
_p9k__param_pat=$'v123\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
|
||||||
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\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+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
|
||||||
_p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'
|
_p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'
|
||||||
|
|
Loading…
Reference in a new issue