jorgebucaran / fisher

A plugin manager for Fish
https://git.io/fisher
MIT License
7.53k stars 257 forks source link

Autoinstall #748

Closed Susensio closed 1 year ago

Susensio commented 1 year ago

How can I configure ~/.config/fish/config.fish to autoinstall fisher, just like fundle does?

Fundle proposes adding if not functions -q fundle; eval (curl -sfL https://git.io/fundle-install); end to config.d. I've tried something similar with fisher with no luck.

Susensio commented 1 year ago

I'm trying to figure out what's happening. Here goes a MRE:

conf.d/fisher.fish

if not functions -q fisher
    curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
end

and the output is

fisher install version 4.4.3
fisher install version 4.4.3
fisher install version 4.4.3
fisher install version 4.4.3
...
fisher install version 4.4.3
fisher install version 4.4.3
^CFetching https://api.github.com/repos/jorgebucaran/fisher/tarball/HEAD

So it seem to be entering a infinite loop when calling fisher install, where it sources conf.d/fisher.fish again. Control+C breaks the loop but fisher command does not work

Susensio commented 1 year ago

I found the problem: fisher install spawns fish subprocesses with fish --command that read configuration files, hence the infinite loop. I've solved it checking if running from interactive session with status is-interactive.

This is the solution I've implemented (maybe this could be added to documentation):

if not functions -q fisher; and status is-interactive
    curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
end

I think this is a workaround and maybe fisher install should call fish --no-config --command, but I don't know for sure if this change could cause any problems.

jorgebucaran commented 1 year ago

Close, but you'd still need to check for interactivity. So, that's the best solution we know of.

You can use && instead of ; and in modern Fish, by the way.

jorgebucaran commented 1 year ago

A PR to improve the docs is always welcome! 🙆‍♂️