Skip to main content

Command line utility to colorize other commands output

Project description

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

Project details


Download files

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

Source Distribution

colorize-1.0.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

colorize-1.0.4-py2.py3-none-any.whl (10.3 kB view details)

Uploaded Python 2Python 3

colorize-1.0.4-py2.7.egg (14.6 kB view details)

Uploaded Egg

File details

Details for the file colorize-1.0.4.tar.gz.

File metadata

  • Download URL: colorize-1.0.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for colorize-1.0.4.tar.gz
Algorithm Hash digest
SHA256 54530e2d2492c112e7623dfa8b6cef52951992230a5a45eb8b7f284a2fbf303b
MD5 6dc3e34406832a66fc236a6be905666f
BLAKE2b-256 31fa728ad86a097846fb8a8bd97ba6c99a940fa9b7c250cc83eece2b1d649411

See more details on using hashes here.

File details

Details for the file colorize-1.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for colorize-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a880667d62c9dee053032c8f8ff2e96b10f52a51119327612e9b80918270e107
MD5 ef7c46370c5042974218c47ec3a9dfda
BLAKE2b-256 e5c7f1c41492464bd0626fadd9fd67ac00ac6c5338649ec697296c4fc46edbb5

See more details on using hashes here.

File details

Details for the file colorize-1.0.4-py2.7.egg.

File metadata

  • Download URL: colorize-1.0.4-py2.7.egg
  • Upload date:
  • Size: 14.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for colorize-1.0.4-py2.7.egg
Algorithm Hash digest
SHA256 30129f3c47d53c7467ed1ade76674fe6fc1994dce525e1b5d4d099901695950c
MD5 f1c9953f7e16a2214a362aca225ca45e
BLAKE2b-256 c8f83cafff014176bbfb719c00a944b44c52cba8dd42040c83b5f6d0665f4558

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page