diff options
author | Andrew Janke <andrew@apjanke.net> | 2015-09-10 04:10:18 -0400 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2020-10-09 17:21:03 +0200 |
commit | ef44416df2e2ae819b13764dbf6ca87ce099ec36 (patch) | |
tree | ddd379838bd4df32048f7b7ff2bf6a073078309c /lib/nvm.zsh | |
parent | fc6c9ca4b40ee1c9ba7fb4b1c8862fb54a8cb1f6 (diff) | |
download | zsh-ef44416df2e2ae819b13764dbf6ca87ce099ec36.tar.gz zsh-ef44416df2e2ae819b13764dbf6ca87ce099ec36.tar.bz2 zsh-ef44416df2e2ae819b13764dbf6ca87ce099ec36.zip |
nvm: use `nvm current` in nvm_prompt_info and look in alternate install locations
This makes it work regardless of where nvm is loaded from. And it uses nvm's
version strings, which distinguish the "system" and "none" NVM environments,
instead of reporting the specific version of the system node.js or erroring,
respectively.
Fixes #4336
Closes #4338
Diffstat (limited to 'lib/nvm.zsh')
-rw-r--r-- | lib/nvm.zsh | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 4a8b6811e..c4f70c849 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,9 +1,8 @@ -# get the node.js version +# get the nvm-controlled node.js version function nvm_prompt_info() { - [[ -f "$NVM_DIR/nvm.sh" ]] || return local nvm_prompt - nvm_prompt=$(node -v 2>/dev/null) - [[ "${nvm_prompt}x" == "x" ]] && return - nvm_prompt=${nvm_prompt:1} + which nvm &>/dev/null || return + nvm_prompt=$(nvm current) + nvm_prompt=${nvm_prompt#v} echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" } |