Support for custom themes using 0-255 terminal color codes #11

Closed
opened 2026-02-16 17:24:50 -05:00 by yindo · 4 comments
Owner

Originally created by @net on GitHub (May 15, 2025).

I would love to be able to define a custom theme using the standard terminal color codes 0-255.

It's not uncommon to configure colors 0-15 to be a specific theme, and then have all your CLI/TUI tools use those colors. This way you don't have to set up the same hex codes in every tool, and you get light/dark theme switching for free (I know opencode has support for light/dark variants based on terminal background, but almost no TUI tool does that).

I personally configure the color codes 0-20 so I can have more colors for things like diff backgrounds, so support for any code 0-255 would be appreciated (and standard).

This would also help support the rare terminal environment that only has 256 color capability.

Example:

{
  "data": {},
  "tui": {
    "theme": "custom",
    "customTheme": {
      "background": 0,
      "foreground": 7,
      "primary": 2,
      "secondary": 3,
    }
  }
}
Originally created by @net on GitHub (May 15, 2025). I would love to be able to define a custom theme using the standard terminal color codes 0-255. It's not uncommon to configure colors 0-15 to be a specific theme, and then have all your CLI/TUI tools use those colors. This way you don't have to set up the same hex codes in every tool, and you get light/dark theme switching for free (I know opencode has support for light/dark variants based on terminal background, but almost no TUI tool does that). I personally configure the color codes 0-20 so I can have more colors for things like diff backgrounds, so support for any code 0-255 would be appreciated (and standard). This would also help support the rare terminal environment that only has 256 color capability. Example: ```json { "data": {}, "tui": { "theme": "custom", "customTheme": { "background": 0, "foreground": 7, "primary": 2, "secondary": 3, } } } ```
yindo closed this issue 2026-02-16 17:24:50 -05:00
Author
Owner

@l0gicgate commented on GitHub (May 15, 2025):

lipgloss supports ANSI 256 colors. However, it's not as simple as just plugging in a few colors.

The theme uses adaptive colors which is a pair of colors for each token. The configuration object would have to be pretty extensive to do this.

Not unfeasible, but not trivial.

Here's an example of how many colors you would need:

// Base colors
theme.PrimaryColor = lipgloss.AdaptiveColor{
	Dark:  flexokiBlue400,
	Light: flexokiBlue600,
}
theme.SecondaryColor = lipgloss.AdaptiveColor{
	Dark:  flexokiPurple400,
	Light: flexokiPurple600,
}
theme.AccentColor = lipgloss.AdaptiveColor{
	Dark:  flexokiOrange400,
	Light: flexokiOrange600,
}

// ...
@l0gicgate commented on GitHub (May 15, 2025): [lipgloss](https://github.com/charmbracelet/lipgloss?tab=readme-ov-file#colors) supports ANSI 256 colors. However, it's not as simple as just plugging in a few colors. The theme uses adaptive colors which is a pair of colors for each token. The configuration object would have to be pretty extensive to do this. Not unfeasible, but not trivial. Here's an example of how many colors you would need: ```go // Base colors theme.PrimaryColor = lipgloss.AdaptiveColor{ Dark: flexokiBlue400, Light: flexokiBlue600, } theme.SecondaryColor = lipgloss.AdaptiveColor{ Dark: flexokiPurple400, Light: flexokiPurple600, } theme.AccentColor = lipgloss.AdaptiveColor{ Dark: flexokiOrange400, Light: flexokiOrange600, } // ...
Author
Owner

@adamdotdevin commented on GitHub (May 15, 2025):

@net added this in d127a1c4eb, lmk what you think!

@adamdotdevin commented on GitHub (May 15, 2025): @net added this in d127a1c4ebe326344dc77fe3d136c033da6031fd, lmk what you think!
Author
Owner

@adamdotdevin commented on GitHub (May 17, 2025):

i'm going to go ahead and close this, it's in the latest release (0.51)!

@adamdotdevin commented on GitHub (May 17, 2025): i'm going to go ahead and close this, it's in the latest release (0.51)!
Author
Owner

@net commented on GitHub (May 19, 2025):

@adamdottv looks perfect, thank you!

@net commented on GitHub (May 19, 2025): @adamdottv looks perfect, thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11