Skip to content

Load bat custom themes #36

@guzmonne

Description

@guzmonne

I have configured some custom themes using bat that I wanted to use with this plugin, but I couldn't load them through the provided configurations.

What I ended up doing was patching the lib.rs save_image() method with this snippet:

    if let Some(path) = &opts.themes_path {
        ha.add_from_folder(path)
            .expect("Failed to load themes on path");
    }

And I am adding the themes_path as part of the Opts struct.

This works since I can now load my custom bat themes using the theme configuration option, but it feels sub-optimal because it gets run every time a new image is created. Since the process itself is very fast, I don't mind, but I was wondering if:

  1. Is there a better place to include loading these themes? Maybe creating a SiliconCache or SiliconCacheBuild function loads them once and makes them available to the user. Similar to what you would do with bat cache --build.
  2. Is there an easier way to accomplish this that I might miss?

Adding an image of the code, I'm referring to it because I love the images created by silicon and this plugin:

silicon_20230326_023847

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions