diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index d48374a..ad10b05 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -78,12 +78,19 @@ _zsh_nvm_lazy_load() { # Add nvm global_binaries+=('nvm') + # Remove any binaries that conflict with current globals + local cmds + cmds=() + for bin in $global_binaries; do + _zsh_nvm_has $bin || cmds+=($bin) + done + # Create function for each command - for cmd in $global_binaries; do + for cmd in $cmds; do # When called, unset all lazy loaders, load nvm then run current command eval "$cmd(){ - unset -f $global_binaries + unset -f $cmds _zsh_nvm_load $cmd \"\$@\" }"