Skip to content

Instantly share code, notes, and snippets.

@KenG98
Created December 11, 2018 23:13
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KenG98/2d084a9859637cdd1614ba27485e2ef9 to your computer and use it in GitHub Desktop.
Save KenG98/2d084a9859637cdd1614ba27485e2ef9 to your computer and use it in GitHub Desktop.
Putting NVM init into a function
# PUT THESE LINES
export NVM_DIR="$HOME/.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
# INTO A FUNCTION
function initnvm {
export NVM_DIR="$HOME/.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
}
# THEN RUN THE FUNCTION WHEN YOU NEED NVM
initnvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment