Skip to content

Instantly share code, notes, and snippets.

@volkancakil
Forked from loucyx/nvm-fix.zsh.sh
Last active December 6, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volkancakil/8637e2ebedbe7f2fb59ffbd3d5c35305 to your computer and use it in GitHub Desktop.
Save volkancakil/8637e2ebedbe7f2fb59ffbd3d5c35305 to your computer and use it in GitHub Desktop.
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type -f __init_nvm)" = function ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
declare -a __node_commands;__node_commands=(nvm `find -L $NVM_DIR/versions/*/*/bin -type f -exec basename {} \; | sort -u`)
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh
unset __node_commands
unset -f __init_nvm
}
for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done
fi
@Abhinav1217
Copy link

Abhinav1217 commented Dec 6, 2018

Hi, I just viewed the diff, Is there any benefit/technical reason for separating declare of __node_commands with its initialization. Or just syntactical aesthetics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment