# # Run 'nvm use' automatically every time there's # a .nvmrc file in the directory. Also, revert to default # version when entering a directory without .nvmrc # enter_directory() { if [[ $PWD == $PREV_PWD ]]; then return fi PREV_PWD=$PWD if [[ -f ".nvmrc" ]]; then nvm use NVM_DIRTY=true elif [[ $NVM_DIRTY = true ]]; then nvm use default NVM_DIRTY=false fi } export PROMPT_COMMAND="$PROMPT_COMMAND; enter_directory"