This is a pretty simple tool/toy which colorizes its input and prints result to
the STDOUT
. Coloring rules are pretty simple: one char - one color.
A char->color
mapping can be easily customized through environment variable.
This project was heavily inspired by this post from @afiskon.
Just install one prerequisite - termcolor library and then run:
$ python termcolor_test.py map.txt
...
Of course you can do some piping:
$ cat map.txt | python termcolor_test.py -
...
Program was tested with Python 2.7 and Python 3.4 and works fine with both. You can test it with your version of interpreter. Just do:
$ TEST=true python termcolor_test.py
If no warnings or errors appeared then everything is OK :)
A mapping char->color
can be customized in a way:
$ export TERMCOLOR_PALETTE="x=red : o=white+"
$ echo -e "xox\nxxo\nooo" | python termcolor_test.py -
Each item of palette (o=white+
for example) contains:
- A char to color
o
- Equality sign
=
- Color name. Possible values:
grey
red
green
yellow
blue
magenta
cyan
white
- Optional color modifier. Here
+
means "bright" (bold
in ANSI Terminal lexicon) and-
means "dark".
You can freely use all of the stuff in this repo. And any kind of PRs and proposals is welcomed.