Skip to content

Instantly share code, notes, and snippets.

@allenhwkim
Last active September 24, 2018 20:17
Show Gist options
  • Save allenhwkim/04f6285e9855b51572d863c698782f34 to your computer and use it in GitHub Desktop.
Save allenhwkim/04f6285e9855b51572d863c698782f34 to your computer and use it in GitHub Desktop.
usage of .nvmrc
# 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;
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