jorgebucaran / fisher

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

Add support for themes #708

Closed nickeb96 closed 2 years ago

nickeb96 commented 2 years ago

Fish 3.4 was released a few weeks ago and allows users to set fish_color_* variables from *.theme files with fish_config theme choose/save <theme name>. (changelog)

Custom themes can be used by placing them in ~/.config/fish/themes/ and it would be really convenient if Fisher could place themes from plugins here.

I think the best way to do this would be to just have the same logic used for functions. So plugin/themes/*.theme could get installed to ~/.config/fish/themes/ the same way plugin/functions/*.fish get installed to ~/.config/fish/functions/ by Fisher.

jorgebucaran commented 2 years ago

This makes sense, but do we just save plugin themes in ~/.config/fish/themes regardless of $fisher_path? Is there a way to make fish_config theme become aware of an arbitrary theme file or themes not present in ~/.config/fish/themes?

nickeb96 commented 2 years ago

It looks like there is no equivalent $fish_theme_path like $fish_functions_path or $fish_completions_path. I think fish_config theme just looks in $__fish_config_dir/themes unless there's some undocumented functionality.

I think the theme directory is sort of like how you can't set custom conf.d directories.

jorgebucaran commented 2 years ago

Gotcha, 👍. Thank you for the info!

I think the theme directory is sort of like how you can't set custom conf.d directories.

Yes, but one can easily replicate that functionality by sourcing every .fish file inside $fisher_path/conf.d. Just saying.

nickeb96 commented 2 years ago

Yes, but one can easily replicate that functionality by sourcing every .fish file inside $fisher_path/conf.d. Just saying.

Never even thought of that!

I'll take a closer look at fish_config theme and see if there are any workarounds for getting it to search in other directories. I know the builtin themes are in (install dir)/fish/share/fish/tools/web_config/themes which seems like a strange place to keep them.

nickeb96 commented 2 years ago

@jorgebucaran it looks like the paths used to search for themes are hardcoded, unfortunately.

fish-shell/.../fish_config.fish (line 145)

I think the best bet is to just have Fisher put the themes in $__fish_config_dir/themes

jorgebucaran commented 2 years ago

@nickeb96 Here you go: https://github.com/jorgebucaran/fisher/pull/717.

There's more room for improvement. Right now only works if your $fisher_path is $__fish_config_dir (the default).

jorgebucaran commented 2 years ago

@nickeb96 Have you had a chance to try this out?

nickeb96 commented 2 years ago

@jorgebucaran Just tested that branch out and it works great. Thanks!

mattmc3 commented 1 year ago

In case someone stumbles upon this issue looking for more details on how to support themes in plugins, here are a couple things that helped me.

First, since there's no such thing as a $fish_theme_path, the only valid place to store themes is $__fish_config_dir/themes (aka: ~/.config/fish/themes). As Jorge described above, that's not gonna work out for you if you have set $fisher_path to something other than $__fish_config_dir.

The simple solution to this is to use a symlink for your themes directory:

cd $__fish_config_dir
mv -f themes themes.bak &>/dev/null
ln -s $fisher_path/themes ./themes

Second, if you did that, now you created a situation where fisher is fully in control of your themes directory, but what if you also want to have local themes in addition to ones managed by fisher? Remember that fisher supports local plugins too, so do something like this:

# make a local theme directory plugin (I called mine "themer")
mkdir -p $__fish_config_dir/plugins/themer/themes

# now install your plugin, using single ticks if you want to keep the
# variable in your fish_plugins file
fisher install '$__fish_config_dir/plugins/themer'

Now, put any local theme files in your themer plugin and you can still use Fisher with a separate $fisher_path.

@jorgebucaran - is it worth documenting this anywhere more visible? Have you considered enabling the GitHub wiki feature for stuff like this? I also opened a ticket with the Fish project to request a $fish_theme_path variable.

jorgebucaran commented 1 year ago

Could you digest this a bit and add it to the readme? I think we can still manage without a wiki (if we must, we can enable it, but perhaps not just yet).