From 05a2d986a439c77122d4d4def70d5b539bc1cb18 Mon Sep 17 00:00:00 2001 From: "Edward J. Jinotti" Date: Thu, 28 Apr 2016 10:49:13 -0400 Subject: [PATCH 1/2] Improve zsh script to revert to default node version when exiting a .nvmrc directory. --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index 4999302..007ecfc 100644 --- a/README.markdown +++ b/README.markdown @@ -199,6 +199,9 @@ autoload -U add-zsh-hook 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 } add-zsh-hook chpwd load-nvmrc From d4d879e6223a6473cecb5f47fb34d49e053d8e1c Mon Sep 17 00:00:00 2001 From: "Edward J. Jinotti" Date: Thu, 28 Apr 2016 11:14:23 -0400 Subject: [PATCH 2/2] zsh script: Check version / .nvmrc on new shell also. --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index 007ecfc..27a143c 100644 --- a/README.markdown +++ b/README.markdown @@ -195,6 +195,7 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e `.nvmrc` file with a string telling nvm which node to `use`: ```zsh +# place this after nvm initialization! autoload -U add-zsh-hook load-nvmrc() { if [[ -f .nvmrc && -r .nvmrc ]]; then @@ -205,6 +206,7 @@ load-nvmrc() { fi } add-zsh-hook chpwd load-nvmrc +load-nvmrc ``` ## License