Skip to content

Instantly share code, notes, and snippets.

Forked from jusopi/
Last active Apr 19, 2021
What would you like to do?
Automatically set node version per project using .nvmrc file
# This will run `nvm use` everytime you change directory, if
# 1. an .nvmrc file is present
# 2. there is no .nvmrc but you're not using your default node
# Add it to your `.bash_profile` (or wherever else is suitable for your setup).
if [ "$PWD" != "$PREV_PWD" ]; then
if [ -e ".nvmrc" ]; then
nvm use;
elif [[ $(nvm version) != $(nvm version default) ]]; then
echo "Reverting to nvm default version."
nvm use default
# bash:
export PROMPT_COMMAND="$PROMPT_COMMAND enter_directory;"
# zsh:
# chpwd_functions=(${chpwd_functions[@]} "enter_directory")

This comment has been minimized.

Copy link

@rjmk rjmk commented Sep 13, 2016

Should line 17 read

export PROMPT_COMMAND="$PROMPT_COMMAND enter_directory;"



This comment has been minimized.

Copy link
Owner Author

@sndrs sndrs commented Dec 8, 2016

yep! edited to reflect that - thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment