|
|
|
@ -1096,7 +1096,7 @@ function _p9k_python_version() {
|
|
|
|
|
fi
|
|
|
|
|
;& # 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]
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
@ -2129,7 +2129,7 @@ _p9k_prompt_docker_machine_init() {
|
|
|
|
|
################################################################
|
|
|
|
|
# GO prompt
|
|
|
|
|
prompt_go_version() {
|
|
|
|
|
_p9k_cached_cmd 0 go version || return
|
|
|
|
|
_p9k_cached_cmd 0 '' go version || return
|
|
|
|
|
[[ $_p9k__ret == (#b)*go([[:digit:].]##)* ]] || return
|
|
|
|
|
local v=$match[1]
|
|
|
|
|
if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then
|
|
|
|
@ -2354,18 +2354,20 @@ _p9k_prompt_load_sync() {
|
|
|
|
|
_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 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() {
|
|
|
|
|
local cmd=$commands[$2]
|
|
|
|
|
local cmd=$commands[$3]
|
|
|
|
|
[[ -n $cmd ]] || return
|
|
|
|
|
if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then
|
|
|
|
|
if ! _p9k_cache_stat_get $0" ${(q)*}" $2 $cmd; then
|
|
|
|
|
local out
|
|
|
|
|
if (( $1 )); then
|
|
|
|
|
out="$($cmd "${@:3}" 2>&1)"
|
|
|
|
|
out="$($cmd "${@:4}" 2>&1)"
|
|
|
|
|
else
|
|
|
|
|
out="$($cmd "${@:3}" 2>/dev/null)"
|
|
|
|
|
out="$($cmd "${@:4}" 2>/dev/null)"
|
|
|
|
|
fi
|
|
|
|
|
_p9k_cache_stat_set $(( ! $? )) "$out"
|
|
|
|
|
fi
|
|
|
|
@ -2376,10 +2378,15 @@ function _p9k_cached_cmd() {
|
|
|
|
|
################################################################
|
|
|
|
|
# Segment to diplay Node version
|
|
|
|
|
prompt_node_version() {
|
|
|
|
|
if (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )); then
|
|
|
|
|
_p9k_upglob package.json && return
|
|
|
|
|
_p9k_upglob package.json
|
|
|
|
|
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
|
|
|
|
|
_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}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2473,10 +2480,10 @@ _p9k_nvm_ls_current() {
|
|
|
|
|
|
|
|
|
|
local nvm_dir=${NVM_DIR:A}
|
|
|
|
|
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}
|
|
|
|
|
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}
|
|
|
|
|
else
|
|
|
|
|
_p9k__ret=system
|
|
|
|
@ -2501,7 +2508,7 @@ _p9k_prompt_nvm_init() {
|
|
|
|
|
# Segment to display NodeEnv
|
|
|
|
|
prompt_nodeenv() {
|
|
|
|
|
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//\%/%%} "
|
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
_p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' && return
|
|
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2613,7 +2620,7 @@ prompt_php_version() {
|
|
|
|
|
if (( _POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY )); then
|
|
|
|
|
_p9k_upglob 'composer.json|*.php' && return
|
|
|
|
|
fi
|
|
|
|
|
_p9k_cached_cmd 0 php --version || return
|
|
|
|
|
_p9k_cached_cmd 0 '' php --version || return
|
|
|
|
|
[[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return
|
|
|
|
|
local v=$match[2]
|
|
|
|
|
_p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}"
|
|
|
|
@ -4362,7 +4369,7 @@ _p9k_prompt_openfoam_init() {
|
|
|
|
|
################################################################
|
|
|
|
|
# Segment to display 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_prompt_segment "$0" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}"
|
|
|
|
|
}
|
|
|
|
@ -8094,7 +8101,7 @@ _p9k_must_init() {
|
|
|
|
|
[[ $sig == $_p9k__param_sig ]] && return 1
|
|
|
|
|
_p9k_deinit
|
|
|
|
|
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+=$'$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'
|
|
|
|
|