Last active
October 19, 2015 10:19
-
-
Save Alex0007/a9a816865f502036cd90 to your computer and use it in GitHub Desktop.
nvm non-blocking sourcing
This file contains hidden or 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
# Replace following lines | |
export NVM_DIR="/home/USERNAME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
init_nvm() | |
{ | |
bin=$(echo $1 | awk '{print $1}') # get first word from command string | |
if [[ -z $NVM_DIR ]] && [[ ! `command -v $bin` ]]; then # if not already inited and no such binary found | |
export NVM_DIR="/home/USERNAME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
fi | |
} | |
preexec_functions+=(init_nvm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment