isaacs / nave

Virtual Environments for Node
ISC License
1.61k stars 137 forks source link

After run `nave use x.x.x` output node and npm versions. #87

Closed rogeriotaques closed 7 years ago

rogeriotaques commented 7 years ago

This's not an issue but a suggestions instead.

It will be really useful if we could have nave outputting the node and npm versions after complete any command that changes current version of these.

isaacs commented 7 years ago

I recommend putting $NAVE in your $PS1 environment variable or $PROMPT_COMMAND. Here's what I use, with node -v when $NAVE is unset, so that nave shells show the node version in a different color: https://github.com/isaacs/dotfiles/blob/master/.extra.bashrc#L766-L787 Here's what it looks like:

screenshot 2017-02-02 22 32 49

It's very noisy to have nave print the version every time you enter or exit a shell, and can disrupt scripts that use it. It used to do this, but it was changed.

isaacs commented 7 years ago

Another option, you could create a file at ~/.naverc with this in it:

# ~/.naverc
echo node@$(node -v)
echo npm@$(npm -v)

and then it'll print out every time you enter a nave environment.

rogeriotaques commented 7 years ago

@isaacs, Thank you for that. Let me try it and come back to you later.

rogeriotaques commented 7 years ago

@isaacs your suggestion has worked like a charm! Thanks.

Just FYI, check what my ~/.naverc looks like:

# Displays NODE and NPM version always NAVE changes it.
echo node@$(node -v)/ npm@$(npm -v)

It outputs the following, where 0.0.0 is the current versions.

$ node@v0.0.0/ npm@0.0.0