Skip to content

Instantly share code, notes, and snippets.

@ch314srun
Forked from fl0w/lazynvm.sh
Last active September 25, 2020 17:19
Show Gist options
  • Select an option

  • Save ch314srun/999dcd867a580fad01bd496354f3eab3 to your computer and use it in GitHub Desktop.

Select an option

Save ch314srun/999dcd867a580fad01bd496354f3eab3 to your computer and use it in GitHub Desktop.
How to speed up shell load while using NVM
# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx
export NVM_DIR=~/.nvm
export NVM_PREFIX=$(brew --prefix nvm)
[ -s "$NVM_PREFIX/nvm.sh" ] && . "$NVM_PREFIX/nvm.sh" # This loads nvm
if [ -f "$NVM_PREFIX/bash_completion" ]; then
[ -s "$NVM_PREFIX/bash_completion" ] && \. "$NVM_PREFIX/bash_completion" # This loads nvm bash_completion
fi
}
nvm() {
lazynvm
nvm $@
}
node() {
lazynvm
node $@
}
npm() {
lazynvm
npm $@
}
npx() {
lazynvm
npx $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment