From 1065a7a5f6fd46cb7909d9485b6741948a3af4d8 Mon Sep 17 00:00:00 2001 From: Nick Nisi Date: Tue, 26 Apr 2016 10:32:31 -0500 Subject: [PATCH] check for nvmrc and switch node version if a .nvmrc file exists in a directory, read it to change node to the correct version Also ignore this file globally from git repos --- git/gitignore_global.symlink | 3 +++ zsh/zshrc.symlink | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/git/gitignore_global.symlink b/git/gitignore_global.symlink index ea4a73b..7bcdb8b 100644 --- a/git/gitignore_global.symlink +++ b/git/gitignore_global.symlink @@ -18,3 +18,6 @@ Icon # typescript command garbage tscommand*.txt + +# nvm - the Node Version Manager +.nvmrc diff --git a/zsh/zshrc.symlink b/zsh/zshrc.symlink index c59b22d..f08392c 100644 --- a/zsh/zshrc.symlink +++ b/zsh/zshrc.symlink @@ -21,7 +21,7 @@ fi # initialize autocomplete -autoload -U compinit +autoload -U compinit add-zsh-hook compinit for config ($ZSH/**/*completion.sh) source $config @@ -63,6 +63,13 @@ fi # source nvm export NVM_DIR=~/.nvm +load-nvmrc() { + if [[ -f .nvmrc && -r .nvmrc ]]; then + nvm use + fi +} +add-zsh-hook chpwd load-nvmrc + if hash brew 2>/dev/null; then source $(brew --prefix nvm)/nvm.sh source `brew --prefix`/etc/profile.d/z.sh