Use terminal theme colors by default #58

Open
opened 2026-02-16 17:25:00 -05:00 by yindo · 22 comments
Owner

Originally created by @net on GitHub (Jun 14, 2025).

Originally assigned to: @adamdotdevin on GitHub.

This one isn't a big problem as long as a theme can be configured that uses terminal color codes instead of hex colors, but I suggest making the default theme use terminal color codes instead of hex colors.

I find it's a better user experience to open a TUI that automatically blends in with the terminal, instead of imposing its own theme. I know it's more difficult and limiting to make a theme using terminal color codes that looks good with most themes, but I do think it's worth the effort. More complex themes with hex codes can be provided as an option; I just find it jarring to open a TUI and have a dramatically different color scheme immediately take over.

Custom full-color themes make for great for screenshots, but are annoying when you actually use the tool and it doesn't match your configured color scheme.

Claude Code isn't perfect with this, but at least it uses the terminal background and foreground colors instead of imposing its own.

I may be alone here though.

Originally created by @net on GitHub (Jun 14, 2025). Originally assigned to: @adamdotdevin on GitHub. This one isn't a big problem as long as a theme can be configured that uses terminal color codes instead of hex colors, but I suggest making the default theme use terminal color codes instead of hex colors. I find it's a better user experience to open a TUI that automatically blends in with the terminal, instead of imposing its own theme. I know it's more difficult and limiting to make a theme using terminal color codes that looks good with most themes, but I do think it's worth the effort. More complex themes with hex codes can be provided as an option; I just find it jarring to open a TUI and have a dramatically different color scheme immediately take over. Custom full-color themes make for great for screenshots, but are annoying when you actually use the tool and it doesn't match your configured color scheme. Claude Code isn't perfect with this, but at least it uses the terminal background and foreground colors instead of imposing its own. I may be alone here though.
Author
Owner

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

i do enjoy the approach you're describing, we went that direction with the terminal.shop tui. that said, for opencode the idea was to take cues from something like neovim (alt screen, themed background colors, etc). in fact, i view opencode as slowly replacing more and more of my time spent in nvim. so the plan today is to stick with a full TUI experience but we do acknowledge that we're only lightly taking advantage of that fact today, and we're not opposed to changing our mind at some point.

@adamdotdevin commented on GitHub (Jun 15, 2025): i do enjoy the approach you're describing, we went that direction with the terminal.shop tui. that said, for opencode the idea was to take cues from something like neovim (alt screen, themed background colors, etc). in fact, i view opencode as slowly replacing more and more of my time spent in nvim. so the plan today is to stick with a full TUI experience but we do acknowledge that we're only lightly taking advantage of that fact today, and we're not opposed to changing our mind at some point.
Author
Owner

@net commented on GitHub (Jun 16, 2025):

In that case how would I create a user theme that uses terminal colors instead of hex colors? Right now it seems like themes have to be compiled in?

I use neovim, but my neovim theme uses terminal color codes so that colors adapt automatically to system color scheme changes.

@net commented on GitHub (Jun 16, 2025): In that case how would I create a user theme that uses terminal colors instead of hex colors? Right now it seems like themes have to be compiled in? I use neovim, but my neovim theme uses terminal color codes so that colors adapt automatically to system color scheme changes.
Author
Owner

@adamdotdevin commented on GitHub (Jun 16, 2025):

you'll be able to define custom themes using 0-255 ansi color codes, of which 0-15 are your terminals user defined color scheme. i'll try to add support in the next couple of days!

@adamdotdevin commented on GitHub (Jun 16, 2025): you'll be able to define custom themes using 0-255 ansi color codes, of which 0-15 are your terminals user defined color scheme. i'll try to add support in the next couple of days!
Author
Owner

@paralin commented on GitHub (Jun 22, 2025):

@adamdotdevin Using with vterm in emacs, we need a "no-theme" option which is just transparent and uses the editor colors.

Here's how it looks currently:

Image
@paralin commented on GitHub (Jun 22, 2025): @adamdotdevin Using with vterm in emacs, we need a "no-theme" option which is just transparent and uses the editor colors. Here's how it looks currently: <img width="1013" alt="Image" src="https://github.com/user-attachments/assets/b0bf16cb-14a1-4732-a44b-3b3c6bcff3ac" />
Author
Owner

@adamdotdevin commented on GitHub (Jun 22, 2025):

so, we do now support custom themes and you can define the colors as 0-15 ansi codes. but, i might need someone to play with that to help me come up with a good default "system" theme in opencode. if i use 0 for the background, for instance, it still isn't transparent. i know how to drop the background TUI wide, but is that what's desired (no background vs ansi color 0)? and what about the rest of the colors? is using the 0-15 color range what people are interested in?

https://opencode.ai/docs/themes/

@adamdotdevin commented on GitHub (Jun 22, 2025): so, we do now support custom themes and you can define the colors as 0-15 ansi codes. but, i might need someone to play with that to help me come up with a good default "system" theme in opencode. if i use 0 for the background, for instance, it still isn't transparent. i know how to drop the background TUI wide, but is that what's desired (no background vs ansi color 0)? and what about the rest of the colors? is using the 0-15 color range what people are interested in? https://opencode.ai/docs/themes/
Author
Owner

@net commented on GitHub (Jun 23, 2025):

For creating a theme that uses the terminal colors that works with a broad range of terminal themes, I would stick to these (admittedly limiting) guidelines:

  • Don't set a background color, except for specific UI elements like a status bar. Just use the terminal's default background.
  • Only use the terminal's default foreground \033[39m, default background \033[49m, and color codes 1-6.
    • The reason for this is there's a lot of variation between themes in whether 0 (white) and 8 (black) are:
      • 0—always black; 8—always white
      • 0—black for dark themes, white for light themes; 8—white for dark themes, black for light themes
      • 0—white for dark themes, black for light themes; 8—black for dark themes, white for light themes
    • Similarly, there's no standard on how the bright variants (8-15) should be treated on dark vs light themes, and some themes like Solarized even map them to completely different UI colors (like different shades of gray).
    • I would also consider avoiding using 3 (yellow) for text for the same reason (little consistency in whether it's a readable color).
  • You can reverse colors using \033[7m, which will use the background color for the foreground and vice-versa (and can be combined with other foreground colors), and which gives a readable result for most themes and colors and let's you use the terminal's configured background color as a foreground color.
  • Make use of bold text where appropriate.
@net commented on GitHub (Jun 23, 2025): For creating a theme that uses the terminal colors that works with a broad range of terminal themes, I would stick to these (admittedly limiting) guidelines: - Don't set a background color, except for specific UI elements like a status bar. Just use the terminal's default background. - Only use the terminal's default foreground `\033[39m`, default background `\033[49m`, and color codes 1-6. - The reason for this is there's a lot of variation between themes in whether 0 (white) and 8 (black) are: - 0—always black; 8—always white - 0—black for dark themes, white for light themes; 8—white for dark themes, black for light themes - 0—white for dark themes, black for light themes; 8—black for dark themes, white for light themes - Similarly, there's no standard on how the bright variants (8-15) should be treated on dark vs light themes, and some themes like Solarized even map them to completely different UI colors (like different shades of gray). - I would also consider avoiding using 3 (yellow) for text for the same reason (little consistency in whether it's a readable color). - You can reverse colors using `\033[7m`, which will use the background color for the foreground and vice-versa (and can be combined with other foreground colors), and which gives a readable result for most themes and colors and let's you use the terminal's configured background color as a foreground color. - Make use of bold text where appropriate.
Author
Owner

@net commented on GitHub (Jun 23, 2025):

If you want to make something that will be the default theme, you might allow yourself to ignore some of those guidelines, or pull in hex colors in some places that look good in most light and dark themes, given that it can be difficult to create something that looks amazing with all those limitations and anything that isn't compatible with a user's terminal theme can be fixed in configuration. (E.g., Claude Code uses Anthropic's orange in some places and I think it looks fine in a lot of both light and dark themes. I think a lot of purple shades can look good in a lot of light and dark themes, and I think you can even pick grays for inactive border-type elements that will look good in most light and dark themes.)

That said, if anyone can create something that looks good with all those limitations, it's you!

@net commented on GitHub (Jun 23, 2025): If you want to make something that will be the _default_ theme, you might allow yourself to ignore some of those guidelines, or pull in hex colors in some places that look good in most light and dark themes, given that it can be difficult to create something that looks amazing with all those limitations and anything that isn't compatible with a user's terminal theme can be fixed in configuration. (E.g., Claude Code uses Anthropic's orange in some places and I think it looks fine in a lot of both light and dark themes. I think a lot of purple shades can look good in a lot of light and dark themes, and I think you can even pick grays for inactive border-type elements that will look good in most light and dark themes.) That said, if anyone can create something that looks good with all those limitations, it's you!
Author
Owner

@net commented on GitHub (Jun 23, 2025):

FWIW, personally I plan to just make my own theme using ansi codes that works specifically for my configured terminal colors.

@net commented on GitHub (Jun 23, 2025): FWIW, personally I plan to just make my own theme using ansi codes that works specifically for my configured terminal colors.
Author
Owner

@adamdotdevin commented on GitHub (Jun 23, 2025):

FWIW, personally I plan to just make my own theme using ansi codes that works specifically for my configured terminal colors.

if you do, i'd love to see a screenshot for inspiration!

@adamdotdevin commented on GitHub (Jun 23, 2025): > FWIW, personally I plan to just make my own theme using ansi codes that works specifically for my configured terminal colors. if you do, i'd love to see a screenshot for inspiration!
Author
Owner

@net commented on GitHub (Jun 25, 2025):

@adamdotdevin looks like the 0-255 ansi codes in opencode aren't using the terminal's configured colors for those codes.

jjui, which also uses lipgloss, had a similar issue that was fixed here https://github.com/idursun/jjui/pull/106/files.

@net commented on GitHub (Jun 25, 2025): @adamdotdevin looks like the 0-255 ansi codes in opencode aren't using the terminal's configured colors for those codes. jjui, which also uses lipgloss, had a similar issue that was fixed here https://github.com/idursun/jjui/pull/106/files.
Author
Owner

@net commented on GitHub (Jun 25, 2025):

(Also however you did it last time here worked correctly https://github.com/sst/opencode/issues/19)

@net commented on GitHub (Jun 25, 2025): (Also however you did it last time here worked correctly https://github.com/sst/opencode/issues/19)
Author
Owner

@adamdotdevin commented on GitHub (Jun 26, 2025):

unfortunately, it wasn't that simple in bubbletea/lipgloss v2, but i got it working with a less-than-ideal implementation; @net let me know what you think about #419 (available in latest release)

@adamdotdevin commented on GitHub (Jun 26, 2025): unfortunately, it wasn't that simple in bubbletea/lipgloss v2, but i got it working with a less-than-ideal implementation; @net let me know what you think about #419 (available in latest release)
Author
Owner

@net commented on GitHub (Jun 26, 2025):

@adamdotdevin that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing this check here needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc.

@net commented on GitHub (Jun 26, 2025): @adamdotdevin that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing [this check here](https://github.com/sst/opencode/pull/419/files#diff-47035fa5e18bae1f90b18e67e4a907415f9d7339005f4488f8fadd524ac1d079R154) needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc.
Author
Owner

@adamdotdevin commented on GitHub (Jun 26, 2025):

@adamdotdevin that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing this check here needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc.

no, this was just a missunderstanding on my part, didn't know terminals allowed customizing 16-255. i'll address this, it's a little more work than just that check, have to build up the map as well

@adamdotdevin commented on GitHub (Jun 26, 2025): > [@adamdotdevin](https://github.com/adamdotdevin) that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing [this check here](https://github.com/sst/opencode/pull/419/files#diff-47035fa5e18bae1f90b18e67e4a907415f9d7339005f4488f8fadd524ac1d079R154) needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc. no, this was just a missunderstanding on my part, didn't know terminals allowed customizing 16-255. i'll address this, it's a little more work than just that check, have to build up the map as well
Author
Owner

@net commented on GitHub (Jun 26, 2025):

Thank you!

@net commented on GitHub (Jun 26, 2025): Thank you!
Author
Owner

@paralin commented on GitHub (Jun 26, 2025):

Image

@adamdotdevin here is how it looks in emacs vterm now. much better, there are still some stray blue underscore characters though.

Image
@paralin commented on GitHub (Jun 26, 2025): <img width="943" alt="Image" src="https://github.com/user-attachments/assets/88609ac5-04be-4589-a807-c9f2d347d3a7" /> @adamdotdevin here is how it looks in emacs vterm now. much better, there are still some stray blue underscore characters though. <img width="444" alt="Image" src="https://github.com/user-attachments/assets/c1abc1b9-2301-4e24-bfe9-7c581e1ec77f" />
Author
Owner

@adamdotdevin commented on GitHub (Jun 26, 2025):

@paralin do you mind opening a new issue for vterm in emacs (or is there one already?), i'd like to download those and troubleshoot but can't right this moment and don't want to forget

@adamdotdevin commented on GitHub (Jun 26, 2025): @paralin do you mind opening a new issue for vterm in emacs (or is there one already?), i'd like to download those and troubleshoot but can't right this moment and don't want to forget
Author
Owner

@paralin commented on GitHub (Jun 26, 2025):

sure #431

@paralin commented on GitHub (Jun 26, 2025): sure #431
Author
Owner

@net commented on GitHub (Oct 13, 2025):

@adamdotdevin that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing this check here needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc.

no, this was just a missunderstanding on my part, didn't know terminals allowed customizing 16-255. i'll address this, it's a little more work than just that check, have to build up the map as well

@adamdotdevin or @thdxr any idea how to fix this?

@net commented on GitHub (Oct 13, 2025): > > [@adamdotdevin](https://github.com/adamdotdevin) that appears to fix it for color codes 0-15, but it's still broken for 16-255. I'm guessing [this check here](https://github.com/sst/opencode/pull/419/files#diff-47035fa5e18bae1f90b18e67e4a907415f9d7339005f4488f8fadd524ac1d079R154) needs be changed to 0-255. Most modern terminals support configuring colors 0-255, and I use codes 16-20 in my theme for colors like "diff added background," "diff removed background," etc. > > no, this was just a missunderstanding on my part, didn't know terminals allowed customizing 16-255. i'll address this, it's a little more work than just that check, have to build up the map as well @adamdotdevin or @thdxr any idea how to fix this?
Author
Owner

@rekram1-node commented on GitHub (Oct 13, 2025):

@net the tui is currently being rewritten with opentui, some theme stuff may be fixed there but that is kinda the blocker, not a whole lot of work will be done to the go tui in the meantime unless there is a large bug

Hopefully in next iteration of tui we can close this out for you!

@rekram1-node commented on GitHub (Oct 13, 2025): @net the tui is currently being rewritten with `opentui`, some theme stuff may be fixed there but that is kinda the blocker, not a whole lot of work will be done to the go tui in the meantime unless there is a large bug Hopefully in next iteration of tui we can close this out for you!
Author
Owner

@net commented on GitHub (Oct 13, 2025):

@rekram1-node great to hear! 🤞🏼 that finally fixes this!

@net commented on GitHub (Oct 13, 2025): @rekram1-node great to hear! 🤞🏼 that finally fixes this!
Author
Owner

@BitCalSaul commented on GitHub (Dec 30, 2025):

Hi @rekram1-node, I'm using OpenCode version 1.0.209. The built-in theme is nice, but when I use Ghostty the colors appear quite dark. Is there a way to adjust the theme colors? Thanks!

@BitCalSaul commented on GitHub (Dec 30, 2025): Hi @rekram1-node, I'm using OpenCode version 1.0.209. The built-in theme is nice, but when I use Ghostty the colors appear quite dark. Is there a way to adjust the theme colors? Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#58