Skip to content

Instantly share code, notes, and snippets.

@xiaolai
Created June 28, 2016 08:42
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save xiaolai/58abfed1d244a0fbb56ed96ac52c4cd8 to your computer and use it in GitHub Desktop.
Save xiaolai/58abfed1d244a0fbb56ed96ac52c4cd8 to your computer and use it in GitHub Desktop.
bash function for load .nvmrc automatically
# for nvm
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
elif [[ $(nvm version) != $(nvm version default) ]]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
cd() { builtin cd "$@"; 'load-nvmrc'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment