1
0
mirror of https://github.com/robbyrussell/oh-my-zsh.git synced 2025-12-06 07:20:40 +01:00

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
This commit is contained in:
Andrew Janke
2015-09-10 04:10:18 -04:00
committed by Marc Cornellà
parent fc6c9ca4b4
commit ef44416df2
2 changed files with 46 additions and 25 deletions

View File

@@ -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}"
}