From ef44416df2e2ae819b13764dbf6ca87ce099ec36 Mon Sep 17 00:00:00 2001 From: Andrew Janke <andrew@apjanke.net> Date: Thu, 10 Sep 2015 04:10:18 -0400 Subject: 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 --- lib/nvm.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/nvm.zsh') 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}" } -- cgit v1.2.3-70-g09d2