3 ms·
You can delegate the choice to the terminal by using ANSI color codes [1]. Then the onus is on the user/terminal developer to make sure the colors they’ve confi
by ratorx 2y ago
You can delegate the choice to the terminal by using ANSI color codes [1]. Then the onus is on the user/terminal developer to make sure the colors they’ve configured (or the defaults provided) are reasonable.
A downside of this is that it is quite restrictive, there are only like 8 colors.
EDIT: I missed the “regardless of the color map” bit, that is a bit unreasonable. Either you trust the terminal emulator or don’t. I think trying to have it both ways is too much.
[1]: https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124 https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2...
- neilv 2y agoFor example, I've seen a program that sets foreground color to a symbolic (not RGB value) yellow, and doesn't set background. While that combination might be legible on some terminals, it's definitely not on all of them. Don't assume that the user's terminal's color map makes all combinations legible.
- Vegenoid 2y agoWhat combinations can be assumed to be legible? I think if a terminal user has their colors configured so that some of the 8 ASCII colors aren’t legible on their background, that’s on them, with the exception of white and black. It seems like the only way to satisfy your ask is to not use color at all.
- neilv 2y agoThe default configurations of most terminals includes illegible color combinations. So I think it's not on every user to somehow design optimal color palette settings on their computer that work in all combinations (if they even can), but rather on the developers of software not to say "Hey, I bet every yellow would be legible on white" or "Yolo, I bet yellow is legible on every background, so I'm just going to set this foreground to yellow and not set background at all."
- Vegenoid 2y ago> The default configurations of most terminals includes illegible color combinations This hasn’t been my experience - while I’m not familiar with a wide breadth of terminal emulators, all the ones I’ve used have a default black background with the ANSI colors being very bright, making them clearly visible. I would again say that if a terminal emulator has some of the standard ANSI colors set to not be visible on their default background, that is the terminal emulator’s problem, as it is clearly undesirable. And of course, once a terminal program starts changing the background color then it can’t make any assumptions about which of the user’s colors will be visible - which is why, as you say, the background color should not be changed without a very good reason. If the bg is set, it should be very easy to switch it to either a “dark mode” or “light mode” to make colors visible. But some assumptions must be made in order to make any use of color, and “the 6 standard ANSI colors (red, green, yellow, magenta, cyan, blue) are visible on the user’s background” seems like it has to be the safest assumption. I am in support of terminal programs respecting a universal configuration to disable color: https://no-color.org/ https://no-color.org/
- deleted 2y ago[deleted]
- jrockway 2y agoI've definitely noticed this going on. `jj log` uses the right colors, but `watch --color jj log` somehow breaks and prints black-on-black.
- mmphosis 2y agoprintf '\e[48;5;196m\e[93m test \e[!p\n'