danhper / fundle

A minimalist package manager for fish shell
MIT License
375 stars 22 forks source link

Auto-install fundle when functions not present #20

Closed enricobacis closed 8 years ago

enricobacis commented 8 years ago

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).

danhper commented 8 years ago

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

enricobacis commented 8 years ago

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

danhper commented 8 years ago

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

enricobacis commented 8 years ago

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

danhper commented 8 years ago

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

enricobacis commented 8 years ago

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

enricobacis commented 8 years ago

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
danhper commented 8 years ago

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.

enricobacis commented 8 years ago

Done in #22 ;)