Skip to content

Instantly share code, notes, and snippets.

@berndbausch
Last active June 11, 2023 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berndbausch/69553114755c1249c0dbfcb9ed9468d4 to your computer and use it in GitHub Desktop.
Save berndbausch/69553114755c1249c0dbfcb9ed9468d4 to your computer and use it in GitHub Desktop.
Linux default colours on dark terminals

I set S_COLORS_SGR="I=32;22:N=36;1:W=35;1:X=31;1:Z=36;22" in my environment. Why?

The output of many command line commands uses colours, which is great for efficiently grasping information at a single glance. Unfortunately, default colours are often not suitable for dark backgrounds; for example, ls displays directories in dark blue, and iostat uses the same colour for most of its numbers. Almost unreadable.

Colours of the two abovementioned tools can be configured with environment variables, namely LS_COLORS and S_COLORS_SGR, respectively. LS_COLORS is very complex; it can be generated with the dircolors command, whose config file is perhaps even more complex but well documented by the dir_colors(5) man page. Thankfully, several useful dircolors configurations have been published, for example https://github.com/seebi/dircolors-solarized.

The colour codes in S_COLORS_SGR conform to a standard named ECMA-48, also documented in the console_codes(4) manual page. I suspect that LS_COLORS use the same standard, although I have not found confirmation.

iostat's default colour configuration is I=32;22:N=34;1:W=35;1:X=31;1:Z=34;22. This means that both zero (Z) and non-zero values (N) are rendered as color 34, which is dark blue. The 1 after the semicolon means "bold", by the way, and 22 stands for "normal intensity". On a dark background, a lighter colour like cyan (code 36) is much more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment