FabioAntunes / fish-nvm

nvm wrapper for fish-shell
MIT License
511 stars 20 forks source link

Quesiton about lazy loading and the`init_nvm` event #41

Closed stv8 closed 5 years ago

stv8 commented 5 years ago

I am a new fish user and first off thanks for the plugin!

I've been trying to find a way to lazy load on a new shell, but I can't seem to find where the event init_nvm is emitted in the function in init.sh.

I think I found a work-around where I can lazy load nvm in fish. What do you think?

function init -a path --on-event load_nvm
  if type -q fenv
    set -q NVM_DIR; or set -gx NVM_DIR ~/.nvm
    set -g nvm_prefix $NVM_DIR

    type -q brew;
      and test -e (brew --prefix)/Cellar/nvm;
        and set -g nvm_prefix (brew --prefix nvm)

    fenv source $nvm_prefix/nvm.sh >/dev/null ^&1
  end

end
function nvm -d "Node version manager"
  emit load_nvm
  if test -e $nvm_prefix/nvm.sh
    if not type -q fenv
      echo "You need to install foreign-env plugin"
      return 1
    end

    fenv source $nvm_prefix/nvm.sh --no-use ';' nvm $argv
  else
    echo "You need to install nvm itself (see https://github.com/creationix/nvm#installation)"
    return 1
  end
end
stv8 commented 5 years ago

oops, wrong repo!

stv8 commented 5 years ago

I meant to post this in the omf nvm plugin repo