danhper/fundle

Auto-install fundle when functions not present

enricobacis opened this issue · 9 comments

At the moment I'm using this snippet to auto-install fundle if it is not present in the system:

# fundle
if [ -s ~/.config/fish/functions/fundle.fish ]
    fundle plugin 'oh-my-fish/theme-bobthefish'
    fundle plugin 'oh-my-fish/plugin-bang-bang'
    fundle init
else
    echo "[Downloading fundle ...]"
    mkdir -p ~/.config/fish/functions
    curl -#fL https://raw.githubusercontent.com/tuvistavie/fundle/master/functions/fundle.fish \
         > ~/.config/fish/functions/fundle.fish; and echo "fundle install" | fish; and exec fish
end

Do you have any better idea? Otherwise we should create a wiki page with this code (Vundle also has an equivalent).

Good idea, I am going to add this to the README, thank you!

It would probably be better to host the script somewhere (github) and then use a classical curl | fish

I think it is a little overkill for 3 lines, what do you think?

Probably yes, but it would allow later modifications. Anyway it's up to you ;)

Even with an installer, we will need to do the if check, so I just added it to the README for now, thank you 😃

Yes, it would have been one line instead of three. Not really much ;)

I improved the solution. I use eval in order not to instantiate another fish environment (which would cause a loop since the fundle is still not downloaded when the config.fish is read again)

if not functions -q fundle; eval (curl -sfL https://git.io/fundle.install); end

The good part of having an installer is that you can also do something like:

curl -sfL https://git.io/fundle.install | fish

The solution I added in the README simply sources the downloaded file, so no need to instantiate another fish environment or anything!

If you really want to add an installer please go ahead and send a PR.

Done in #22 ;)