Skip to content

Instantly share code, notes, and snippets.

@nnance
Last active February 4, 2019 20:56
Show Gist options
  • Save nnance/08d552c31da40f6224d994e3c426a768 to your computer and use it in GitHub Desktop.
Save nnance/08d552c31da40f6224d994e3c426a768 to your computer and use it in GitHub Desktop.
Make NVM lazy load
nvm() {
unset -f nvm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm "$@"
}
node() {
unset -f node
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
node "$@"
}
npm() {
unset -f npm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
npm "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment