mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-17 02:00:07 +00:00
nvm: improve default detection
This is also (marginally) faster than before.
This commit is contained in:
parent
0b2483cf6d
commit
38d5f4d056
1 changed files with 8 additions and 5 deletions
|
@ -889,13 +889,16 @@ prompt_node_version() {
|
||||||
# Node version from NVM
|
# Node version from NVM
|
||||||
# Only prints the segment if different than the default value
|
# Only prints the segment if different than the default value
|
||||||
prompt_nvm() {
|
prompt_nvm() {
|
||||||
[[ ! $(type nvm) =~ 'nvm is a shell function'* ]] && return
|
local node_version nvm_default
|
||||||
local node_version=$(nvm current)
|
(( $+functions[nvm_version] )) || return
|
||||||
[[ -z "${node_version}" ]] || [[ ${node_version} = "none" ]] && return
|
|
||||||
local nvm_default=$(cat $NVM_DIR/alias/default)
|
node_version=$(nvm_version current)
|
||||||
|
[[ -z "${node_version}" || ${node_version} == "none" ]] && return
|
||||||
|
|
||||||
|
nvm_default=$(nvm_version default)
|
||||||
[[ "$node_version" =~ "$nvm_default" ]] && return
|
[[ "$node_version" =~ "$nvm_default" ]] && return
|
||||||
|
|
||||||
$1_prompt_segment "$0" "$2" "green" "011" "${node_version:1}" 'NODE_ICON'
|
$1_prompt_segment "$0" "$2" "magenta" "black" "${node_version:1}" 'NODE_ICON'
|
||||||
}
|
}
|
||||||
|
|
||||||
# NodeEnv Prompt
|
# NodeEnv Prompt
|
||||||
|
|
Loading…
Reference in a new issue