Giter Club home page Giter Club logo

termcolor-test's Introduction

termcolor_test

What is it

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.

Usage

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 :)

"Pallete" customization

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:

  1. A char to color o
  2. Equality sign =
  3. Color name. Possible values:
    • grey
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
  4. Optional color modifier. Here + means "bright" (bold in ANSI Terminal lexicon) and - means "dark".

Contribution

You can freely use all of the stuff in this repo. And any kind of PRs and proposals is welcomed.

termcolor-test's People

Contributors

astynax avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.