diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 9dde3a26..72736c4b 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -3,3 +3,15 @@ # Load nvm if it exists [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" + +# Look for .nvmrc in directories. If found, change to that version of node. +autoload -Uz add-zsh-hook +load-nvmrc() { + if [[ -f .nvmrc && -r .nvmrc ]]; then + nvm use --delete-prefix + elif [[ -f package.json && -r package.json ]]; then + nvm use --delete-prefix v6.11.1 + fi +} +add-zsh-hook chpwd load-nvmrc +load-nvmrc