Created
April 14, 2021 18:11
-
-
Save chfour/db6573a2cfa5c6c80f5e42e201576725 to your computer and use it in GitHub Desktop.
nvmisslow.sh: A shell script that only loads nvm when it's needed
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
#!/bin/bash | |
# nvmisslow.sh: loads nvm only when needed | |
# because nvm is slow | |
# source from or paste into your shell's .rc | |
# this is a list of commands that will trigger __initnvm. | |
# if you have globally installed node modules, add them here | |
declare -a __node_cmds=('nvm' 'node' 'npm') | |
__initnvm(){ | |
for i in "${__node_cmds[@]}"; do; unalias $i; done | |
source /usr/share/nvm/init-nvm.sh # you may need to change this, but idk, that's where it was on my machine | |
unset __node_cmds; unset -f __initnvm | |
} | |
for i in "${__node_cmds[@]}"; do; alias $i="__initnvm;$i"; done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment