Skip to content

Instantly share code, notes, and snippets.

@grrowl
Created February 24, 2020 12:54
Show Gist options
  • Save grrowl/cec975ecfe690d13918f40ff5827fecb to your computer and use it in GitHub Desktop.
Save grrowl/cec975ecfe690d13918f40ff5827fecb to your computer and use it in GitHub Desktop.
#!/bin/bash
function lazy_nvm {
unset -f nvm
unset -f npm
unset -f node
unset -f npx
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # linux
[ -s "$(brew --prefix nvm)/nvm.sh" ] && source $(brew --prefix nvm)/nvm.sh # osx
}
# aliases
function nvm { lazy_nvm; nvm "$@"; }
function npm { lazy_nvm; npm "$@"; }
function node { lazy_nvm; node "$@"; }
function npx { lazy_nvm; npx "$@"; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment