diff options
author | Christian Höltje <docwhat@gerf.org> | 2017-05-04 08:27:56 +0300 |
---|---|---|
committer | Christian Höltje <docwhat@gerf.org> | 2017-05-13 05:14:44 +0300 |
commit | 38d5f4d056027984290f97ea60ede9cc74494f3e (patch) | |
tree | 4a541688fe088d1970db865f248bc14d3ae65584 /powerlevel9k.zsh-theme | |
parent | 0b2483cf6d3f778413c16b6985ff6c02dcdd1f34 (diff) |
nvm: improve default detection
This is also (marginally) faster than before.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..d99b6e38 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -889,13 +889,16 @@ prompt_node_version() { # Node version from NVM # Only prints the segment if different than the default value prompt_nvm() { - [[ ! $(type nvm) =~ 'nvm is a shell function'* ]] && return - local node_version=$(nvm current) - [[ -z "${node_version}" ]] || [[ ${node_version} = "none" ]] && return - local nvm_default=$(cat $NVM_DIR/alias/default) + local node_version nvm_default + (( $+functions[nvm_version] )) || return + + node_version=$(nvm_version current) + [[ -z "${node_version}" || ${node_version} == "none" ]] && return + + nvm_default=$(nvm_version default) [[ "$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 |