Skip to content

Instantly share code, notes, and snippets.

@zfael
Forked from allenhwkim/.bash_profile
Last active October 23, 2018 12:59
Show Gist options
  • Save zfael/1e79cbe0b3e9cb9cf49d6ef85953a339 to your computer and use it in GitHub Desktop.
Save zfael/1e79cbe0b3e9cb9cf49d6ef85953a339 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 $(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