-
-
Save zfael/1e79cbe0b3e9cb9cf49d6ef85953a339 to your computer and use it in GitHub Desktop.
usage of .nvmrc
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
# To use this, add .nvmrc with contents of 'N.N.N' to your project. e.g. 0.12.7 | |
# Add the following to the end of .bash_profile or .bashrc | |
# | |
# if directory is changed | |
# if `.nvmrc` is found execute `nvm use` | |
# if `package.json` is round execute `nvm use default` | |
enter_directory() { | |
if [ "$PWD" != "$PREV_PWD" ]; then | |
PREV_PWD="$PWD"; | |
if [ -e ".nvmrc" ]; then | |
nvm use $(cat .nvmrc); | |
elif [ -e "package.json" ]; then | |
nvm use default | |
fi | |
fi | |
} | |
export PROMPT_COMMAND="$PROMP_COMMAND enter_directory;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment