jorgebucaran / fisher

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

Support alternative fish_plugins file names #645

Closed Jomik closed 3 years ago

Jomik commented 3 years ago

I save my fish_plugins and fish configuration to my dotfiles repo. I have a need to install some plugins on some machines. That's why I would love to be able to have a common fish_plugins for shared, and then be able to "merge" additional ones. In my case based on hostname, as I do for my general fish config here: https://github.com/Jomik/dotfiles/blob/cf5329f812a161160ce80fc8396edd457589e81b/.config/fish/config.fish#L2

Is there a good way to do this currently? I could keep my own fish_plugins.shared and then just generate fish_plugins, at some point. But that seems very dirty.

jorgebucaran commented 3 years ago

Is there a good way to do what? I'm not clear what this issue is about.

Jomik commented 3 years ago

I currently have two machines I use fish on. I load some configuration by sourcing a .fish file based on the hostname of the machine. Now I find myself needing to install a plugin only on my Mac, but not on my Linux machine. I am "unable" to do that currently, as I want to have my fish_plugins in git. So I essentially want a

if hostname is tamaskan
  install these plugins
endif

if hostname is DKR2817
  install these plugins
endif

I do this for "normal" fish configuration by sourcing a file named after the hostname of the machine. As seen here I have two files, tamaskan.fish and DKR2817.fish, I source them here.

Jomik commented 3 years ago

I guess what I am asking is to be able to configure where/what the fish_plugins file is called. Because then I could just set that to be (hostname).fish_plugins and I would be happy 👍

jorgebucaran commented 3 years ago

So, you'd still have two *.fish_plugins in your dotfiles, but tell Fisher to use the right one using something like:

set --global fisher_fish_plugins (hostname).fish_plugins
Jomik commented 3 years ago

Exactly, that would be great! Even better would be if that could be a list of files, so that I could have a list of shared plugins and one specific for my current machine.

jorgebucaran commented 3 years ago

What if your fish_plugins was a symlink to the right file in each system? Could be done in a script you'd run once as part of your dotfiles setup. Or no symlinks, just copy the right fish_plugins to your ~/.config/fish/ directory.

mv (hostname).fish_plugins ~/.config/fish/fish_plugins
Jomik commented 3 years ago

I did consider that - I do not like having to symlink anything, as my setup is currently just "clone a git repo" and it runs. So I do not have a symlink manager as such, I use https://github.com/alfunx/dotfiles.sh/ Bit unsure how I would maintain the file, if I copy/move the file, as I would again like not having additional logic I need to remember to run. I guess I could want to be able to react to fisher installs/uninstalls in general.

jorgebucaran commented 3 years ago

Plugins can run commands on install, update, and uninstall (remove) via events. Using a snippet is another option.

Bit unsure how I would maintain the file, if I copy/move the file, as I would again like not having additional logic I need to remember to run.

Well, I guess you'd git clone your dotfiles, then run your own ./setup script that does what you need.

Jomik commented 3 years ago

Yeah. Not pretty solutions though, sadly. Would much prefer if it was possible to tell fisher what fish_plugins file to use, by setting a variable. 😄

jorgebucaran commented 3 years ago

I do not like having to symlink anything... ...I would again like not having additional logic I need to remember to run.

Out of curiosity, your disinclination to either solution stems from the maintenance burden? Or is it that you'd just prefer to keep your dotfiles setup as simple as a git clone and be done with it?

jorgebucaran commented 3 years ago

Two more alternatives. Either way, you install the same plugins everywhere.

1) One plugin. Put everything in it, then conditionally run commands depending on the hostname:

switch (hostname)
    case DKR2817
    case tamaskan # 🐕
end

2) Two plugins. One for each system. Activate only if it runs in the right hostname by checking the file name.

if test (hostname) = (status filename | string replace ".fish" "")
    # ...
end
Jomik commented 3 years ago

I do not like having to symlink anything... ...I would again like not having additional logic I need to remember to run.

Out of curiosity, your disinclination to either solution stems from the maintenance burden? Or is it that you'd just prefer to keep your dotfiles setup as simple as a git clone and be done with it?

Both, but primarily the first would be a concern. I like that I simply commit files and it all just works..

I am a bit unsure what you mean with one vs two plugins. I am not talking about writing my own plugin, but more specifically in this case I would like fish_rbenv on my mac, but not on my linux machine.

Sourcing my standard fish configuration works fine by just having a .fish file named after the hostname of my machine, but your two plugin thing seems to be a nice solution for that case as well.

jorgebucaran commented 3 years ago

I'm not too keen on adding a fisher_fish_plugins variable. I believe that the default is, albeit not perfect, adequate for the majority of people and I don't want to introduce a new feature at this time. I'm sorry to disappoint you.

All things considered, I may revisit this later, but probably not until 4.2.

jorgebucaran commented 3 years ago

Customizing the location of your fish_plugins is intriguing, but it's not immediately clear why anyone would want to do it. I know this would've helped with your configuration, but maybe only fortuitously. No one would be looking at this feature and think: so that's how you create a conditional setup (or whatever it is we want to call what you have).

You can certainly solve this without help from Fisher. I presented a couple of alternatives too. You don't consider them "pretty solutions", but maybe what you mean is: "that's more work for me", or perhaps we have a different definition of pretty. I think your use case is atypical, and Fisher serves you better in the long run by staying out of your way.

Ultimately, I feel that letting users change the location of fish_plugins has not been properly justified and I am usually stingy about adding new features. How would I communicate this to everyone? You can customize fish_plugins. Why, you ask? We don't really know, surprise us! It's not going to cut it.

Jomik commented 3 years ago

No, that is perfectly fine and understandable. I also agree with that philosophy. You are right that the solutions you provided would work, albeit making it so that I have to maintain the fish_plugins more than if I just write fisher install ..., as I need to separate it. But it works ! 👍