Skip to content

Instantly share code, notes, and snippets.

@nicholascloud
Last active September 21, 2017 14:35
Show Gist options
  • Save nicholascloud/e94b81da151487a2aee48beef0cbd9d9 to your computer and use it in GitHub Desktop.
Save nicholascloud/e94b81da151487a2aee48beef0cbd9d9 to your computer and use it in GitHub Desktop.
bash - override cd to test for .nvmrc and instruct nvm to change node versions if present
# hook into the cd command to test for the presence
# of .npmrc and then switch node versions based on that
cd() {
builtin cd "$@"
if [ -d $NVM_DIR ]
then
if [ -f ./.nvmrc ]
then
# cat ./.nvmrc
LOCAL_NODE_VERSION=`cat .nvmrc`
nvm use $LOCAL_NODE_VERSION
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment