Skip to content

Instantly share code, notes, and snippets.

@farmisen
Last active April 8, 2018 23:47
Show Gist options
  • Save farmisen/1fadf25677e2d45e1ff1c4a9647fe572 to your computer and use it in GitHub Desktop.
Save farmisen/1fadf25677e2d45e1ff1c4a9647fe572 to your computer and use it in GitHub Desktop.
autoselect node version when enter directory

To have a specific node version used ped project add the following to you ~/.profile and create a .nvmrc file with the node version at the root of the project.

enter_directory() {
  if [[ $PWD == $PREV_PWD ]]; then
    return
  fi

  PREV_PWD=$PWD
  [[ -f ".nvmrc" ]] && nvm use
}

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