From e391fd94a70e0d3ae2b5d6472eb45eafb8f11222 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 10 Sep 2015 04:10:18 -0400 Subject: [PATCH] lib/nvm: Use `which nvm` and `nvm current` 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. --- lib/nvm.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 4a8b6811e..1238b46ec 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,9 +1,9 @@ -# 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}" }