mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-24 04:29:25 +02:00
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.
This commit is contained in:
parent
ae21102030
commit
e391fd94a7
1 changed files with 4 additions and 4 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
# get the node.js version
|
# get the nvm-controlled node.js version
|
||||||
function nvm_prompt_info() {
|
function nvm_prompt_info() {
|
||||||
[[ -f "$NVM_DIR/nvm.sh" ]] || return
|
[[ -f "$NVM_DIR/nvm.sh" ]] || return
|
||||||
local nvm_prompt
|
local nvm_prompt
|
||||||
nvm_prompt=$(node -v 2>/dev/null)
|
which nvm &>/dev/null || return
|
||||||
[[ "${nvm_prompt}x" == "x" ]] && return
|
nvm_prompt=$(nvm current)
|
||||||
nvm_prompt=${nvm_prompt:1}
|
nvm_prompt=${nvm_prompt#v}
|
||||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue