Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you think it would be a good idea to let the user manually load NVM via a shell function? #1826

Closed
DougBeney opened this issue Jun 6, 2018 · 2 comments · Fixed by #2317

Comments

@DougBeney
Copy link

Currently, NVM adds the following to your bashrc / zshrc:

[ -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

Those two lines cause a noticable delay every time you open the terminal.

Since a user probably isn't using NVM all the time (Only to install node once for most of us), what if instead those two lines were added in a shell function like this? :

function loadnvm
{
  [ -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
}

With this, whenever I want to use nvm, I simply type "loadnvm" and then I could use the commands I need in that shell session.

@ljharb
Copy link
Member

ljharb commented Jun 6, 2018

You can add --no-use - ie, change [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" to [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use, and then it won't auto-use, which is the only slow part.

@zeorin
Copy link
Contributor

zeorin commented Jun 9, 2018

Also see #730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants