Skip to content

Instantly share code, notes, and snippets.

@grrowl
Created February 24, 2020 12:54
Show Gist options
  • Select an option

  • Save grrowl/cec975ecfe690d13918f40ff5827fecb to your computer and use it in GitHub Desktop.

Select an option

Save grrowl/cec975ecfe690d13918f40ff5827fecb to your computer and use it in GitHub Desktop.

Revisions

  1. grrowl created this gist Feb 24, 2020.
    18 changes: 18 additions & 0 deletions lazy-nvm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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 "$@"; }