Skip to content

Instantly share code, notes, and snippets.

@pokorson
Forked from xiaolai/nvmrc
Created January 10, 2017 10:47
Show Gist options
  • Save pokorson/a7f7529d1e463fd6464811e0a7831ec8 to your computer and use it in GitHub Desktop.
Save pokorson/a7f7529d1e463fd6464811e0a7831ec8 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