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

Add a theme that uses terminal colors #490

Closed
ariasuni opened this issue Jan 31, 2019 · 21 comments

Comments

Projects
None yet
@ariasuni
Copy link

commented Jan 31, 2019

I spent a lot of time to customize my terminal named colors, and I wish there was a bat theme that uses them so it doesn’t look bad in my terminal.

The benefit is that it provides a backup theme that works across terminals if no other theme works with the terminal theme.

@sharkdp

This comment has been minimized.

Copy link
Owner

commented Feb 4, 2019

Thank you for the feedback - interesting idea.

Unfortunately, highlighting themes typically need to define more than the 8 basic ANSI colors, so this would really just be a subpar fallback solution. It's also unclear to me if this could be implemented with a reasonable effort. I currently can't think of a good way to make this work with the current Sublime-Syntax theme infrastructure.

@Trucido

This comment has been minimized.

Copy link

commented Feb 25, 2019

Not sure how the sublime-syntax stuff works but I think some themes do exist which only define 8 colors (technically 16) such as possibly the Base​16 Color Schemes (Unconfirmed, I haven't looked into this yet but I know most of the base16 shell themes come in 16 or 256 variants.)

Other than that, when bat fails me I've been piping through pygmentize -g
I've been meaning to look into this for my windows build, since powershell/pwsh acts weird sometimes with crazy colors.

@wbolster

This comment has been minimized.

Copy link

commented Mar 29, 2019

i regularly switch my terminal (and gnome and emacs) themes between a dark and a light version, depending on the light circumstances (e.g. dark or sunny environment) to avoid eye strain.

unfortunately none of the built-in bat themes are readable on both backgrounds, which basically renders bat output useless roughly half of the time.

i have settled on solarized dark/light for a long time, but this issue is not specific to these (yellowish and dark blue) background colours.

i would love to see only the basic 8 (?) colour terminal palette as one of of the themes, since those are extremely legible on both backgrounds (it's one of the design goals of the solarized palette).

here are two screenshots to illustrate the problem.
image

image

@sharkdp

This comment has been minimized.

Copy link
Owner

commented Apr 4, 2019

I see the need, but I really don't know how that would be implemented with Sublime Text Themes, which are used by bat.

@sharkdp sharkdp added the help wanted label Apr 4, 2019

@wbolster

This comment has been minimized.

Copy link

commented Apr 4, 2019

perhaps the colours can be "rounded" to the nearest ansi color?

@sharkdp

This comment has been minimized.

Copy link
Owner

commented Apr 7, 2019

You can round a 24-bit ANSI color to the nearest 8-bit ANSI color (we actually do this in bat if the terminal does not support truecolor, see to_ansi_color in src/terminal.rs). But how would you round to 16 base colors? We don't know how these look like because they are user-configured.

@wbolster

This comment has been minimized.

Copy link

commented Apr 7, 2019

well i guess just rounding to bright red green blue cyan magenta yellow (6 extreme colours, "#ff0000") and "base" would work.

@trapd00r

This comment has been minimized.

Copy link

commented Apr 7, 2019

Keep in mind that all 256 colors are (in most cases) user configurable.

@zackhsi

This comment has been minimized.

Copy link

commented Apr 7, 2019

And adding to the above, many of today's color schemes support true color, 256, and 16. For example, onedark.vim has a configurable named g:onedark_termcolors:

set to 16 to use your terminal emulator's native 16 colors

@sharkdp

This comment has been minimized.

Copy link
Owner

commented Apr 8, 2019

well i guess just rounding to bright red green blue cyan magenta yellow (6 extreme colours, "#ff0000") and "base" would work.

Okay. That could be worth a try.

Keep in mind that all 256 colors are (in most cases) user configurable.

Oh dear, I didn't know this was possible.

And adding to the above, many of today's color schemes support true color, 256, and 16. For example, onedark.vim has a configurable named g:onedark_termcolors:

Yes. But that doesn't really help, right? The user would have to set these in the terminal emulator. bat has no control over that.

@zackhsi

This comment has been minimized.

Copy link

commented Apr 8, 2019

Yes. But that doesn't really help, right? The user would have to set these in the terminal emulator. bat has no control over that.

bat would emit the proper ansi color codes (e.g. for red, magenta, green), and the terminal would color them however the user configured. One's person's red can differ from another person's red, and bat could happily support both of them by using standard color codes.

@trapd00r

This comment has been minimized.

Copy link

commented Apr 9, 2019

Oh dear, I didn't know this was possible.

Put this in your shellrc ;)

for i in {0..255}; do printf "\033]4;$i;rgb:ff/00/00\033\\"; done
_redefine

@LandonSchropp

This comment has been minimized.

Copy link

commented Apr 10, 2019

I'd love to see this as well. I use a custom color theme in my personal terminal that I've already carefully configured. It would be great if bat could pick that up and run with it. I have 24-bit colors enabled, but even if I pick a theme, it's not going to match my color scheme.

@mk12

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

I'm working on adding support for base16 themes using the 16 ANSI colours. I should have a pull request ready tomorrow. I might also try adding a very basic 8-color theme that should look decent on any terminal emulator with the 8 colours being roughly similar to their names (0=black, 1=red, 2=green, etc.)

@LandonSchropp

This comment has been minimized.

Copy link

commented Apr 12, 2019

@mk12 Awesome!

@trishume

This comment has been minimized.

Copy link

commented Apr 14, 2019

As the author of syntect, which does the highlighting for bat, my recommendation is to implement it using a special case where colors with an alpha value of 0 and a red value between 0 and 16 get their color rendered as the ANSI color corresponding to the red value.

It's somewhat of a hack, but the TextMate-theme specific logic in syntect has a bunch of optimizations that would be annoying to replicate in a custom highlighting pipeline. It also allows bat to re-use its existing system for custom themes, and shouldn't be too hard to implement.

@sharkdp sharkdp closed this in #543 May 8, 2019

@sharkdp

This comment has been minimized.

Copy link
Owner

commented May 15, 2019

The new themes by @mk12 are now included in v0.11.0.

@cben

This comment has been minimized.

Copy link

commented Jun 19, 2019

Is it just me, or none of the new 3 themes deliver on the Solarized promise of single theme working well with light & dark bg?

(this is gnome-terminal with I think built-in Solarized colors)
base16 is similar to ansi-dark in having some text bright grey that's unredable on bright bg.
(TwoDark that you see at the top actually remains one of the better ones under both)

I'll try to work on a 4th theme that works wells on Solarized light & dark, unless anyone wants to beat me.

@bricewge

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

I can confirm that those bat themes doesn't work well with a terminal using solarized colors.

Unfortunately it's seems to me that the issue is not specific to bat but come from a deeper incompatibility between base16 architecture themes and solarized theme on how the 16 colors ought to be used, especially the monotones ones. base16 think of colors 0 to 7 as a darkening shade for dark themes and a lightening shade for light ones. solarized on the other hand use the same darkening shade for both theme but exclude 3 colors from the shade in a symmetricly manner to mark the difference between the dark and light variant (see 4. Precision, symmetry).

Using https://github.com/paulcpederson/solarized-sublime.git with bat works great though.

@cben

This comment has been minimized.

Copy link

commented Jun 19, 2019

Huh. Something I never realized before is that when I flip the terminal between "solarized dark" and "solarized light", only chars styled with default foreground and background change; but the palette remains assigned to colors 0–15 colors in a fixed, non-inverting manner:

solarized-flip

This seems in-line with https://github.com/altercation/solarized#the-values intent.
IIUC the idea was that the palette supports easy inversion but applications have to use it in 2 ways.
This is also consistent with terminals having sort-of fixed meanings for colors 0 (black) – 7 (white).

However it's NOT what I was hoping for 😉 I really want to flip the terminal theme and have existing output re-styled.
I'll try to research whether any terminal solarized themes flip the neutral colors like that?

Another option is a theme that only uses default fg + the 8 accent colors, but not the neutral tones. Actually can add one "middle" tone too, especially for low-attention things like line numbers.

@mk12

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

@cben If you want to flip between solarized light and solarized dark, I recommend using the base16 versions of the solarized themes for your terminal (for the Gnome terminal, that's https://github.com/aaron-williamson/base16-gnome-terminal), and then using the base16 bat theme I created.

Making a bat theme that works well flipping between light and dark -- that is, a single ansi theme instead of ansi-light and ansi-dark -- is not possible because typical terminal themes use fixed slots for "black-ish" and "white-ish," not "foreground" and "background." This is the problem that base16 solves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.