Skip to main content

Give some color to your (remote) TTY!!

VERSION

DOWNLOADS

TESTS

COVERAGE

WHEEL

Latest PyPI version

Number of PyPI downloads

Travis results

Coveralls results_

Wheel Status

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 zip and use it with:

python colorize-X.Y.Z.zip -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 files for colorize 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorize 1.0.3
File Size Uploaded
colorize-1.0.3.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for colorize 1.0.3
File Interpreter ABI Platform
colorize-1.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.9 kB

Release files / colorize-1.0.3.tar.gz

Download URL colorize-1.0.3.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7eec7485675be67f9323af7f53fd5b59cc06e5aa717d66ba2c18340c73b0d1e
BLAKE2b-256 checksum
How to use checksums
a741793339aba88de22d691c271b2241871b9358b213802a71fc386de17ec699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / colorize-1.0.3-py2.py3-none-any.whl

Download URL colorize-1.0.3-py2.py3-none-any.whl
Size 9.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
95a6c76522c16be0a54410939ac387b62e1f7fddbf8c298f95085667f232d005
BLAKE2b-256 checksum
How to use checksums
64a671a2e4d8a380a8afad506f2a04813f3cd8637346c77c87c55c2580a11fd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.1.0

3 release files

1.0.4

3 release files

This release

1.0.3 This release

2 release files

1.0.2

3 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page