CLI usage

Discovering terminal support

To see examples of the formatting supported by your terminal, run:

ansiscape --example
ansiscape

Welcome to the ansiscape example!

These are heavy and light.

These are italic and blackletter.

These are single underlined, double underlined and overlined.

These are blinking slowly and blinking fast.

These are inverted, concealed (that's concealed) and struck.

These are the first alternative font, the second alternative font, the third alternative font, the fourth alternative font, the fifth alternative font, the sixth alternative font, the seventh alternative font, the eighth alternative font and the ninth alternative font.

This entire line uses proportional spacing.

These are black, red, green, yellow, blue, magenta, cyan, white, bright black, bright red, bright green, bright yellow, bright blue, bright magenta, bright cyan and bright white foreground.

These are black, red, green, yellow, blue, magenta, cyan, white, bright black, bright red, bright green, bright yellow, bright blue, bright magenta, bright cyan and bright white background.

Here's some foreground RGB:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And some background RGB:












These are framed and encircled.

These are the single line under/right, double line under/right, single line over/left, double line over/left and stress ideograms.

Not all terminals support all codes, so please don't be too sad if some of the examples didn't work for you.

Converting encoded text to explanatory JSON

The ansiscape CLI will read from stdin and write to stdout a JSON document describing the input.

For example, to interpret a simple string:

echo -e "\033[1mhello world\033[22m" | ansiscape
[{"weight": 1},"hello world",{"weight": 0}]

Info

The -e is needed with echo to prevent echo escaping the escape codes.

You can pipe the output of any command into ansiscape to generate explanatory JSON:

ls --color | ansiscape
[{"background": -1, "foreground": 4, "weight": 1},"ansiscape",{"background": -1},"\n",{"foreground": 4, "weight": 1},"ansiscape.egg-info",{"background": -1},"\n",{"foreground": 2, "weight": 1},"build.sh",{"background": -1},"\ncoverage.xml\n",{"foreground": 4, "weight": 1},"dist",{"background": -1},"\n",{"foreground": 4, "weight": 1},"docs",{"background": -1},"\n",{"foreground": 4, "weight": 1},"htmlcov",{"background": -1},"\nLICENSE\n",{"foreground": 2, "weight": 1},"lint.sh",{"background": -1},"\nMANIFEST.in\nmkdocs.yml\nmypy.ini\nPipfile\nPipfile.lock\npyproject.toml\nREADME.md\nsetup.py\n",{"foreground": 2, "weight": 1},"test-cli.sh",{"background": -1},"\n",{"foreground": 4, "weight": 1},"tests",{"background": -1},"\n",{"foreground": 2, "weight": 1},"test.sh",{"background": -1}]

See the enum documentation to translate the integer values to meaningful interpretations.

If your application doesn't emit escape codes through pipes

Some applications omit escape codes from their output if they detect they're running in a non-interactive shell (i.e. their output is being redirected or piped).

Tools like NaughTTY can fool these applications into emitting their codes by wrapping them in a pseudo-terminal.

To use NaughTTY with ansiscape:

naughtty APP | ansiscape