Last active
August 19, 2024 18:48
-
-
Save YSaxon/a1c97490794e8d1f668715cefb04808e to your computer and use it in GitHub Desktop.
Lazy load homebrew node to speed up shell init time
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
# Add this to your zshrc etc | |
# modified from #http://broken-by.me/lazy-load-nvm/ | |
setup_nvm(){ | |
unset -f nvm node npm | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm | |
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion | |
} | |
nvm() { | |
setup_nvm | |
nvm "$@" | |
} | |
node() { | |
setup_nvm | |
node "$@" | |
} | |
npm() { | |
setup_nvm | |
npm "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment