Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for themes #708

Closed
nickeb96 opened this issue Mar 28, 2022 · 10 comments
Closed

Add support for themes #708

nickeb96 opened this issue Mar 28, 2022 · 10 comments
Labels
enhancement New feature or request

Comments

@nickeb96
Copy link

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 jorgebucaran added the enhancement New feature or request label Mar 28, 2022
@jorgebucaran
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

@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 added a commit that referenced this issue Jun 6, 2022
@jorgebucaran
Copy link
Owner

@nickeb96 Here you go: #717.

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

@jorgebucaran
Copy link
Owner

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

@nickeb96
Copy link
Author

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

@mattmc3
Copy link
Contributor

mattmc3 commented Jan 9, 2023

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants