cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.75k stars 176 forks source link

Allow colors to be configured via config file #405

Closed exokernel closed 1 month ago

exokernel commented 3 months ago

What?

Allow the colors to be configured via ~/.config/mcfly/config.toml. This can also serve as a starting point for other config options. It has settings for both dark-mode and light-mode colors.

Example (my current color config for dark background):

[colors]

[colors.menubar]
bg = "black"
fg = "red"

[colors.darkmode]
prompt = "cyan"
timing = "yellow"
results_selection_fg = "cyan"
results_selection_bg = "black"
results_selection_hl = "red"

Why?

I love mcfly but the default colors aren't working for me. I thought it might be nice if they could be set in a config file. This adds that capability by reading a basic colors config in a ~/.config file for mcfly. It's written such that any errors or missing config will silently just fall back to using the defaults, which I've kept the same.

Caveats

Reads the config file each time mcfly is run so that does add some overhead. An alternative might be to have different hard-coded color modes that could be enabled by a command line flag. This would mean no file read but also that you'd be limited to the set of color modes that are supported. The Colors struct used in the project seems pretty limited to begin with though (i.e. there's not a huge number of options). Some colors also didn't work for me in some contexts (e.g. setting the menubar to certain colors didn't always work for me).

Thoughts and Feedback

Please let me know if you have thoughts on better ways to do this, if you'd like to see more extensive testing, etc.

cantino commented 2 months ago

Thank you for this PR. Making a few changes in https://github.com/cantino/mcfly/pull/407

cantino commented 1 month ago

Merged in https://github.com/cantino/mcfly/pull/407, thanks @exokernel!

cantino commented 1 month ago

Released in https://github.com/cantino/mcfly/releases/tag/v0.8.5