Fast Zsh plugin to install, update, and load nvm, with optional lazy-loading and .nvmrc auto-use support.
Repository: https://github.com/seebeen/zsh-nvm-x
- Installs
nvmautomatically if missing - Eager load or lazy load
nvm nvm upgrade/nvm revertwrapper support.nvmrcauto-use on directory changes- Optional completion loading
- Installs
rcandnightlyaliases through wrapper helpers
Important
Set NVM_* options before loading zsh-nvm-x.
With plugin managers, place your export ... lines in shell init before plugin bootstrap.
git clone https://github.com/seebeen/zsh-nvm-x /path/to/zsh-nvm-x
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
source /path/to/zsh-nvm-x/zsh-nvm-x.plugin.zshgit clone https://github.com/seebeen/zsh-nvm-x ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-nvm-xThen in ~/.zshrc:
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
plugins=(... zsh-nvm-x)
# later in the file:
# source $ZSH/oh-my-zsh.shexport NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
antigen bundle seebeen/zsh-nvm-x
antigen applyAdd to your plugins list:
seebeen/zsh-nvm-x
And in your shell init (before sourcing Antibody output):
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=trueexport NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
zinit light seebeen/zsh-nvm-xexport NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
zplug "seebeen/zsh-nvm-x"export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
zgenom load seebeen/zsh-nvm-xIn your ~/.zimrc:
zmodule seebeen/zsh-nvm-xSet options in your shell init before ZimFW initialization:
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=trueThen rebuild:
zimfw installIn ~/.config/sheldon/plugins.toml:
[plugins.zsh-nvm-x]
github = "seebeen/zsh-nvm-x"And in ~/.zshrc before eval "$(sheldon source)":
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=trueSet these before loading zsh-nvm-x (typically near the top of your ~/.zshrc or equivalent).
| Option | Default | Description |
|---|---|---|
NVM_DIR |
$HOME/.nvm |
Where nvm is installed/loaded from. |
NVM_COMPLETION |
false |
When true, loads nvm completion ($NVM_DIR/bash_completion). |
NVM_LAZY_LOAD |
false |
When true, creates lazy wrappers and loads nvm only when needed. |
NVM_LAZY_LOAD_EXTRA_COMMANDS |
() |
Extra commands that should also trigger lazy load. |
NVM_NO_USE |
false |
When true, loads nvm with --no-use (does not auto-select Node version). |
NVM_AUTO_USE |
false |
When true, auto-runs nvm use / nvm install based on .nvmrc when changing directories. |
ZSH_NVM_NO_LOAD |
false |
Debug/testing switch to skip plugin initialization entirely. |
export NVM_LAZY_LOAD=true
export NVM_AUTO_USE=true
export NVM_COMPLETION=trueexport NVM_LAZY_LOAD=true
typeset -ga NVM_LAZY_LOAD_EXTRA_COMMANDS
NVM_LAZY_LOAD_EXTRA_COMMANDS+=(vim nvim)Note
On first run, a missing nvm installation is bootstrapped automatically into NVM_DIR.
- If
nvmis missing, the plugin clonesnvmintoNVM_DIRand checks out the latest release tag. - If lazy load is enabled, wrappers are created for
nvm, global npm binaries, and any extra commands you define. - With
NVM_AUTO_USE=true:- entering a directory with
.nvmrcrunsnvm use(ornvm installif needed) - leaving that tree can revert to
nvmdefault
- entering a directory with
Warning
nvm upgrade and nvm revert modify your local nvm checkout.
Use them intentionally, especially in shared or reproducible environments.
nvm upgrade– upgrade installednvmto latest tagnvm revert– revert to previousnvmtagnvm install rc– install latest RC and alias asrcnvm install nightly– install latest nightly and alias asnightly
nvm_update is kept as a compatibility alias and prints a deprecation message.
zsh-nvm-x.plugin.zsh– entrypoint/bootstraplib/zsh-nvm-x-state.zsh– internal statelib/zsh-nvm-x-core.zsh– install/load/completion/core helperslib/zsh-nvm-x-lazy.zsh– lazy-load implementationlib/zsh-nvm-x-auto-use.zsh–.nvmrcauto-use hook logiclib/zsh-nvm-x-wrappers.zsh– wrapper commands (upgrade,revert,installhelpers)
sudo dnf install -y zsh git curl makeClone and enter the project:
git clone https://github.com/seebeen/zsh-nvm-x
cd zsh-nvm-xInstall ShellSpec (if needed):
curl -fsSL https://git.io/shellspec | sh -s -- --yesRun all checks:
make testUseful commands:
make lint-shell– syntax check plugin, libraries, and specsmake test-unit– run ShellSpec suitemake test-smoke– run smoke tests undertest/smoke/
- Keep behavior flags/env vars documented (
NVM_*,ZSH_NVM_NO_LOAD) - Add/update tests for behavioral changes
- Run
make testbefore opening a PR - Update README when user-facing behavior changes
This repository uses ShellSpec for unit/integration-style shell tests and simple smoke scripts for startup/lazy-load validation.
sudo dnf install -y zsh git curl makeInstall ShellSpec (if not already installed):
curl -fsSL https://git.io/shellspec | sh -s -- --yesmake testUseful targets:
make lint-shell– syntax-check plugin, library, and spec filesmake test-unit– run ShellSpec suitemake test-smoke– run smoke tests fromtest/smoke/
CI is configured in .github/workflows/test.yml and runs the same test pipeline on Ubuntu and macOS.
This project is a fork/rework of the original zsh-nvm by Luke Childs.
- Original author: Luke Childs
- Original repo: https://github.com/lukechilds/zsh-nvm
- Fork maintainer: Sibin Grasic sibin.grasic@oblak.studio
- Fork repo: https://github.com/seebeen/zsh-nvm-x
Huge thanks to Luke for the original work.
MIT — see LICENSE.