Update nvm.plugin.zsh

This commit is contained in:
ZhenHappy 2017-02-04 16:10:11 +08:00 committed by GitHub
parent f18b4aedf5
commit bb29ba1359

View File

@ -1,6 +1,21 @@
# if homebrew installed
_homebrew-installed() {
type brew &> /dev/null
}
# if nvm from homebrew installed
_nvm-from-homebrew-installed() {
brew --prefix nvm &> /dev/null
}
# Set NVM_DIR if it isn't already defined
[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
# Load nvm if it exists
[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
[[ -f "$(brew --prefix nvm)/nvm.sh" ]] && source "$(brew --prefix nvm)/nvm.sh"
if [[ -f "$NVM_DIR/nvm.sh" ]] ; then
source "$NVM_DIR/nvm.sh"
elif _homebrew-installed && _nvm-from-homebrew-installed ; then
source "$(brew --prefix nvm)/nvm.sh"
else
unset NVM_DIR
fi