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?
I changed the event in init.fish to load_nvm (this seemed to prevent it from running on new shell startup)
I added emit load_nvm to functions/nvm.sh
Now every time you run nvm $arg it will load it on demand
Is there any problem with this approach?
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
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 ininit.sh
.I think I found a work-around where I can lazy load nvm in fish. What do you think?
init.fish
toload_nvm
(this seemed to prevent it from running on new shell startup)emit load_nvm
tofunctions/nvm.sh
nvm $arg
it will load it on demand