Created
October 9, 2017 23:35
-
-
Save dlee/98a7cd0fd012099466ca1b13ae0fd308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export SKIP_INSTALL_AVN="Y" | |
export NVM_DIR="$HOME/.nvm" | |
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
if [ -s "$NVM_DIR/nvm.sh" ]; then | |
# https://github.com/creationix/nvm/blob/d91b6197f3f60e1e7a332acf69a9b90e83120f06/nvm.sh#L265-L282 | |
# https://github.com/creationix/nvm#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file | |
load_nvmrc() { | |
local dir="${PWD}" | |
while [ -n "${dir}" ]; do | |
[ -e "${dir}/.nvmrc" ] && break | |
dir=${dir%/*} | |
done | |
local nvmrc_path="${dir}/.nvmrc" | |
if [ -e "$nvmrc_path" ]; then | |
which nvm > /dev/null || source "$NVM_DIR/nvm.sh" | |
[ $(nvm version "$(cat "${nvmrc_path}")") != $(nvm version) ] && nvm use | |
elif [ -n "$NVM_BIN" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
autoload -U add-zsh-hook | |
add-zsh-hook chpwd load_nvmrc | |
load_nvmrc | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment