Skip to content

Instantly share code, notes, and snippets.

@mike239x
Last active August 30, 2019 09:39
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 mike239x/c32721e6c972de49decf16d92daa38d5 to your computer and use it in GitHub Desktop.
Save mike239x/c32721e6c972de49decf16d92daa38d5 to your computer and use it in GitHub Desktop.
Thoughts on colors in the terminal

Here is an idea: how about we drastically modify the way the coloring is done in terminals and in text in general?

Reasoning:

  1. Right now it is really hard to make the text you write colorful.
  2. The control flow for the terminal is quite convoluted - most programs stop coloring output if the pipe doesn't lead to tty, so your bash scripts end up looking like a mess.
  3. External highlighters (or absence thereof) can change the coloring (of your code for example), which may be not desired.

What do we have?

  1. ANSI codes. Works only in terminals with color support (which is like 100% of them), works even better with terminals with true color support (which is a bit less than 100% of them). By the way, this gist and many of its forks contain a list of terminals supporting true color.

    Example: This \E[31mpart of text\E[0m is colored in red.

    \E there represents the escape key-code.

  2. CSS. Web-only system which is fairy good though also fairy complex. The applications are spread a bit wider than just web-pages, because electron exists. The biggest downside being that it directly interacts only with html, and no human writes directly in html.

    Example: This <span style="color:red">part of text</span> is colored red.

To be continued...

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