Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Command line utility to colorize other commands output

Project Description

Give some color to your (remote) TTY!!

VERSION DOWNLOADS TESTS COVERAGE WHEEL

And it is free. Checkout the Source code.

Installation and Usage

Two options: to install it in your system/project:

pip install colorize

And you can use it with:

python -m colorize -h

Or just download the lastest egg and use it with:

python colorize-X.Y.Z-pyN.M.egg -h

Now, you have two ways to use it:

Rendering the output

Just execute:

$ command to execute | python -m colorize

If you need to render both the stdout and the stderr:

$ command to execute |& python -m colorize

This method works well with too long outputs

As runner

Other way to use it:

$ python -m colorize command to execute

This method can do disgusting things with too long outputs.

Options

You can change the output format with the argument -f or --format. It uses the same format that logging, so you can use any of its special variables, like:

You can combine them as you wish. Example:

$ python -m colorize -- echo foo
foo
$ python -m colorize -f "%(asctime)s - %(levelname).2s: %(message)s" -- echo foo
05-29 08:43:09 - IN: foo
$ python -m colorize -f "%(levelname).2s %(asctime)s - %(message)s" -- echo foo
IN 05-29 08:44:17 - foo

Default date format is %m-%d %H:%M:%S, but you can change it with --date-format:

$ python -m colorize -f "%(asctime)s" --date-format="%H:%M:%S" -- echo foo
08:44:17
$ python -m colorize -f "%(asctime)s" --date-format="%H %M %S" -- echo foo
08 44 17

Configuration File

It will find a configuration file in the current directory, in the home directory or in the default path directory. The first one found will be used. So, it will search for:

  • ./.colorize.conf
  • $HOME/.configuration/colorize/colorize.conf
  • /etc/colorize/colorize.conf

The format for this file is very easy: it is a CSV file with next fields:

# regular expression to highlight (quoted) , bold output , foreground color , background color
  "^=+$"                                   , 1           , white            ,
  "^=+$"                                   , true        , white            , black
  "^=+$"                                   , 0           , red              , white
  "^=+$"                                   , false       , brown            , magenta

Available colors:

  • black
  • white
  • red
  • green
  • blue
  • brown
  • gray
  • magenta
  • cyan

And that’s all.

Example to simulate colordiff

To emulate colordiff, just use this configuration file:

"^>.*",                0, blue
"^<.*",                0, red
"^\d+,?\d*c\d+,?\d*$", 0, magenta

That’s enough :D

Release History

Release History

This version
History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
colorize-1.0.4-py2.7.egg (14.6 kB) Copy SHA256 Checksum SHA256 2.7 Egg Sep 13, 2014
colorize-1.0.4-py2.py3-none-any.whl (10.3 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Sep 13, 2014
colorize-1.0.4.tar.gz (7.3 kB) Copy SHA256 Checksum SHA256 Source Sep 13, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting