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

nvm use #{version} --default #13

Closed
yfeldblum opened this issue Dec 19, 2010 · 6 comments
Closed

nvm use #{version} --default #13

yfeldblum opened this issue Dec 19, 2010 · 6 comments

Comments

@yfeldblum
Copy link

nvm use #{version} --default should cause future shells for the same user automatically to be using node-#{version}. When using the --default option, the choice of version to use should be persistent between sessions.

This would be similar to how rvm use #{version} --default works for managing Ruby versions.

@creationix
Copy link
Collaborator

Neat idea, but it's fairly hard to implement. How would I store the preference?

@yfeldblum
Copy link
Author

I'm not entirely sure how this would work. The best bet is to discover what RVM is already doing.

One possibility, though, is to store the value in a file somewhere within in ~/.nvm (for example, ~/.nvm/prefs/default). The shell script would check for this file every time it is run. If the file exists, and if its contents are exactly equal to the name of a version of Node.js that is currently installed via NVM, then the shell script would also mimic an invocation of nvm use #{version}. Since the shell script is only sourced from within ~/.bashrc, it only runs once per shell session.

@creationix
Copy link
Collaborator

That sounds good, I'll take a patch for it. I don't think my bash skills are up to the challenge.

@zzak
Copy link

zzak commented Feb 21, 2011

Hello @creationix, et al,

I've started hacking on this and would appreciate a review, here's the compare

So far I've just tried implementing the ~/.nvm/prefs/default hook. I had to change how $NVM_DIR is looked up, as I wanted this to execute upon session creation; Not entirely sure this is the best way to do this.

Try it out, just create a symlink like:

ln -s ~/.nvm/v0.4.0/bin/node ~/.nvm/prefs/default

Then just add this modified version of nvm to your PATH:

. nvm.sh

Note: you will likely need to create the ~/.nvm/prefs directory first ;)

Thanks!

@creationix
Copy link
Collaborator

This is implemented via the new alias command.

nvm alias default v0.4.1

or if you're brave

nvm alias default stable

@zzak
Copy link

zzak commented Feb 25, 2011

Awesome, thanks for the update Tim!

This issue was closed.
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

No branches or pull requests

3 participants