How to Choose Colors for Your CLI Applications (2023)
Posted by kruuuder 3 hours ago
Comments
Comment by tolciho 5 minutes ago
Comment by layer8 1 hour ago
When going beyond that, the colors really need to be configurable on the application.
Comment by s_dev 44 minutes ago
Comment by makapuf 9 minutes ago
Comment by jph 20 minutes ago
export STDOUT_COLOR_START='[34m'
export STDOUT_COLOR_STOP='[0m'
export STDERR_COLOR_START='[31m'
export STDERR_COLOR_STOP='[0m'
In your shell script: print_stdout() {
printf %s%s%s\\n "${STDOUT_COLOR_START:-}" "$*" "${STDOUT_COLOR_STOP:-}"
}
print_stderr() {
>&2 printf %s%s%s\\n "${STDERR_COLOR_START:-}" "$*" "${STDERR_COLOR_STOP:-}"
}
Source: https://github.com/sixarm/unix-shell-script-kitThe source also has functions for nocolor, and detecting a dumb terminal setup that doesn't use colors, etc.
Comment by kps 7 minutes ago
tty -s
2. Don't hardcode escape sequences. Use (e.g.) export STDOUT_COLOR_START="`tput setaf 4`".Comment by direwolf20 16 minutes ago
Comment by Rygian 14 minutes ago
Comment by j4cobgarby 2 hours ago
The CSS to make the terminals look like iTerm was smooth, to the point I read them as screenshots.
Comment by BeetleB 1 hour ago
Comment by mrob 1 hour ago
Comment by kps 1 hour ago
Not differently for each program's output.
Comment by mrob 1 hour ago
Comment by sceptic123 53 minutes ago
Comment by mrob 29 minutes ago
Comment by skydhash 25 minutes ago
Comment by fassssst 52 minutes ago
Comment by altcognito 40 minutes ago
Comment by red_admiral 1 hour ago
Comment by busterarm 2 hours ago
8% of men of Northern European descent (and 0.4% of women) are red-green colorblind. That'd be a terrible choice. Use blue-orange, blue-red, or purple-green.
Comment by Etheryte 1 hour ago
Comment by account42 1 hour ago
Comment by makapuf 2 hours ago
Comment by xenophonf 1 hour ago
Comment by makapuf 15 minutes ago
Comment by craftkiller 1 hour ago
I'd like to recommend rofimoji. I have it bound to a hotkey, so whenever I want to type an emoji, I just hit that hotkey and then a window pops up with my most recent emoji already visible at the top. Then I start typing in words that describe the emoji that I want like "crying" and it filters the list. Finally I select one and it pastes it into whatever text box I had selected before I hit the hotkey. My only complaint is I wish it worked for all unicode codepoints instead of just the emoji.
Comment by skydhash 2 hours ago
Comment by tczMUFlmoNk 2 hours ago
Comment by mrob 1 hour ago
Comment by skydhash 1 hour ago
Comment by jammcq 58 minutes ago
Comment by bradrn 47 minutes ago
Comment by red_admiral 1 hour ago
Comment by account42 1 hour ago
Comment by thinking_cactus 32 minutes ago
Comment by hnsmhthrow 31 minutes ago
Comment by alias_neo 1 hour ago
I think it's safe to set a standard colour-set so that it's immediately usable, but beyond that, a user should be customising to their requirements.
Perception differs among people; many of the colours OP listed as unreadable, were barely an issue, bright yellow being the only one I could unequivocally agree on. Perhaps display type, configuration and colour calibration is an important factor, as well as individual perception, ambient conditions, brightness levels, contrast, and perhaps even more variables have a significant effect.
I've also learned, since adding an OLED Monitor to my desk alongside the IPS ones, that it's possible to have too much contrast; brightly coloured text alongside pixels that are literally off can be just as problematic to read at times, as low-contrast.
Comment by ori_b 25 minutes ago
Comment by seanwilson 1 hour ago
Ideally, instead of the CLI app switching to "bright green", it would pick a "bright contrasting green". So if the terminal background was dark, it would pick bright green, and for light background it would pick a darker green. There isn't CLI app implementations for this? This is similar to how you'd implement dark mode in a web app.
Comment by account42 1 hour ago
The responsibility for this lies with the color scheme not the terminal program.
Comment by JoshTriplett 1 hour ago
Comment by takluyver 1 hour ago
Comment by JoshTriplett 55 minutes ago
Comment by alt187 1 hour ago
Comment by sroussey 2 hours ago
Problem there is you can’t change css so at the moment the systems color preference changes thing will look bad.
Important considerations for custom formatters.
Comment by sroussey 1 hour ago
https://github.com/workglow-dev/workglow/blob/main/docs/deve...
Play with it here using dev tools (you can ignore the website itself): https://workglow-web.netlify.app/
Docs including útil for checking dark mode: https://github.com/workglow-dev/workglow/tree/main/packages/...
Comment by bitwize 1 hour ago
Comment by xenophonf 2 hours ago
Keep it plain text. Regular, old, boring output is good.
Comment by maximgeorge 1 hour ago
Comment by the_gipsy 2 hours ago
Comment by taswellian 2 hours ago
Comment by JoshTriplett 1 hour ago
Comment by Arch-TK 2 hours ago
If your software does something dumb when my theme switches to black on white during the day then I am just going to avoid using it...
Comment by strogonoff 2 hours ago
Personally I alternate between light on dark and dark on light (the latter sometimes together with OS-wide colour inversion feature).
Comment by skydhash 2 hours ago
Dark background is hell for anyone with astigmatism. It’s fine with 80x24 (vga text mode), but for anything higher feels like light needles on the retina. With astigmatism everything that is bright and small is duplicated, which means small characters is very difficult to read.
Comment by keepamovin 1 hour ago
Colors, have been a perpetual nightmare.