Created
May 19, 2016 06:14
-
-
Save alwayrun/38ca5bb35a22451dec469f04671d30a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this into your $HOME/.zshrc to call nvm use automatically whenever you enter a directory that contains an .nvmrc file with a string telling nvm which node to use: | |
# place this after nvm initialization! | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
if [[ -f .nvmrc && -r .nvmrc ]]; then | |
nvm use | |
elif [[ $(nvm version) != $(nvm version default) ]]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/tomsquest/nvm-auto-use.zsh/blob/master/nvm-auto-use.zsh
This had an interesting addition to this script; if you don't have the .nvmrc version installed, it installed it for you. Just something to consider :)