Implement .node-version file in Bash & NVM
30 Aug 13:28

Simply add to your ~/.bashrc:

enter_directory() {
  if [[ $PWD == $PREV_PWD ]]; then return; fi
  PREV_PWD=$PWD
  nodefile=.node-version
  [[ -f "$nodefile" ]] && nvm use $(cat $nodefile)
}
export PROMPT_COMMAND=enter_directory

Comments

Empty! You must sign in to add comments.