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

Adaptive Theme Selection Based on the Terminal Color Scheme #12098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luca-schlecker
Copy link
Contributor

@luca-schlecker luca-schlecker commented Nov 20, 2024

Fixes #8899, #10281

Overview

Introduce theme = { light = "<name>", dark = "<name>" } syntax inside config.toml to allow adaptive theme selection based on the terminal color scheme.

Theme selection is based on terminal-colorsaurus which has also been used in delta and bat.

Considerations

  • If the theme detection fails, dark mode is chosen by default.
  • The new syntax using an untagged enum ensures existing configs remain valid.
  • Theme validation (ensuring the theme name exists) is only done for the detected theme. This would defer errors if a missing theme is specified but reduces code changes.
  • terminal-colorsaurus' code is only called in case an adaptive theme has been specified, guaranteeing practically zero overhead for static themes.

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

Successfully merging this pull request may close these issues.

Automatically select light/dark theme variant
1 participant