zshrc: new: lazy-load nvm

This commit is contained in:
Marco D'Agostini 2020-10-05 16:44:33 -05:00
parent 391ca9ceb2
commit 5a4356122e

View File

@ -66,6 +66,21 @@ alias ipython=ipython3
function mkcd () { mkdir -p "$@" && cd "$@"; } function mkcd () { mkdir -p "$@" && cd "$@"; }
``` ```
### Lazy-load nvm
```bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . $NVM_DIR/nvm.sh --no-use; # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . $NVM_DIR/bash_completion; # This loads nvm bash_completion
__nvm_load_node () {
unalias node npm npx;
nvm use 2> /dev/null || nvm use default;
}
alias node='__nvm_load_node; node $@'
alias npm='__nvm_load_node; npm $@'
alias npx='__nvm_load_node; npx $@'
```
### Enable most ### Enable most
```bash ```bash