Skip to content

Instantly share code, notes, and snippets.

@wvankuipers
Created April 10, 2016 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvankuipers/d20b56688450d525b34230ecf5124f45 to your computer and use it in GitHub Desktop.
Save wvankuipers/d20b56688450d525b34230ecf5124f45 to your computer and use it in GitHub Desktop.
# Bash
# Add the following to your .bash_profile
function cd {
# actually change the directory with all args passed to the function
builtin cd "$@"
# if there's a regular file named "todo.txt"...
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
fi
}
# ZSH
# Add the following to a zsh script file
autoload -U add-zsh-hook
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
fi
}
add-zsh-hook chpwd load-nvmrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment