This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Credits: dv, iblis, pi314, su (in alphabetical order)

VT100-ColorPrint is a tool for coloring output easily and quickly without to remember VT100 color attributes definitions. It provides:

  1. Two print functions: print_ and pprint_.
  2. A shell command: colorprint.
  3. Use the environment variable COLORPRINT_CUSTOM to define color names.


pip install vt100-colorprint


The functions

The package provides functions print_ and pprint_ which work like built-in functions print and pprint:

>>> from colorprint import print_ as print, pprint_ as pprint

Member function

You can set color with member function as below:

>>> print.reverse.underscore('abc', 123)
abc 123
>>> pprint.reverse(dict(zip(range(3), 'abc')), depth=1)
{0: 'a', 1: 'b', 2: 'c'}


You can alos set color with parameter colors:

>>> colors = ['reverse', 'underscore']
>>> print(colors=colors, *range(3))
0 1 2


You can customize your favorite color and set a color name for convenience.

>>> from colorprint import color_attr_mapping
>>> color_attr_mapping['ocean'] = color_attr_mapping['bright'] + (38,5,27)
>>> color_attr_mapping['ocean']
(1, 38, 5, 27)
>>> print.ocean('abc', 123)
abc 123

The shell command

The command provides a shell command colorprint coloring streaming data line by line:

colorprint --help


You can just select fields and color to highlight:

tail -f log | colorprint --fields 1 3 5 bright blue

In addition, you can choose fields with Python`s slice notation:

tail -f log | colorprint --fields 1:6:2 bright blue

You can also choose the last field like Python`s index notation while you don`t know how many fields:

tail -f log | colorprint --fields -1 bright blue

By default, the separator is regexp “s+”; you can set othere separator such as “,”:

colorprint --separator ',' --fields -1 bright blue < data.csv


The number of field works as AWK field number when greater than zero; otherwise, it works as Python`s index/slice notation.


You can use regexp to find string to color:

tail -f log | colorprint --pattern '\[:\d+\]' bright blue

The command supports regexp group, so you can indicate which group you want to color:

tail -f log | colorprint --pattern '\[(\d+):(\d+)]' 1 2 bright blue

Short arguments

The command provides short arguments for convenience.

long argument short argument
–fields -F
–separator -S
–pattern -P


Set color

The package has built-in color names, but you can set favorite color for frequent usage:

export COLORPRINT_CUSTOM='grey=1,30 blueviolet=38,5,57'

It can be defined in multiple lines for more readibility:

     grey = 1, 30
     blueviolet = 38, 5, 57

The command has argument for checking custom color:

colorprint --show-names

Find color

The command has two arguments: --show16 and --show256. They will show all colors or given color attributes. You can use them to find your desire.

colorprint --show256 38 5 57

Customize command

Shell (such as Bourne Shell, Bash, …etc) usually provides alias, function, and variable. You can use these features to customize commmands. Below are some examples:

  • Since --fields arguments always being used:

    alias cpf='colorprint --fields'
    cpf 1 3 5 reverse < file
  • Since some colors always being used:

    cpfr () { colorprint --fields  "$@" reverse -S ',' ; }
    cpfr -1 < csv_file
  • Since there are some highlight forms always being used:

    # "hl" stands for "highlight"
    export hlpid="--pattern '\[(\d+)\]' 1 reverse"
    export hldate="--pattern '(\d+):(\d+):(\d+)' 1 2 3 yellow"
    colorprint $hlpid $hldate < log

Frequently Asked Questions

About the package:

  • Q:The name VT100-ColorPrint is verbose. Why not use shorter name, such as ColorPrint?
    A:Because it has been taken. See
  • Q:Can it run on Microsoft Windows?
    A:What is Microsoft Windows?
  • Q:I think the functinos (i.e. print_ and pprint_) are useless for my production.
    A:Yes. These functions are just for temporary usage; defining your own coloring functions is better when you know which color you prefered.
  • Q:Is there a need to provide customizing color?
    A:Yes. The display results are not all the same on different terminal emulaters.

About the funtions:

  • Q:Why not remove postfix of print_ and pprint_?
    A:It is for not confusing built-in print and pprint.
  • Q:Why there are two ways to set color on print function? What is the difference?
    A:Setting color with parameter is more pythonic, and setting color with member function is more obvious.
  • Q:With member function, why do you put “print” at the start of line but the end?
    A:We think it is more intuitive. Besides, it`s no effect between the two style with Vim.

About the command:

  • Q:I think the command name “colorprint” is too long, and the parameters are too flexible. I don`t like set color every time. I only have few use cases.
    A:You can use shell features. Refer to Customize command.

About customizing color:

  • Q:Why not provide a configuration file like ~/.colorprint?
    A:Flat is better than nested, there is no need to write it in specified file since it is just used for defining colors.

The Built-in Color Names

name value
reset 0
bold [0] 1
bright 1
dim 2
underscore 4
underlined [0] 4
blink 5
reverse 7
hidden 8
black 30
red 31
green 32
yellow 33
blue 34
magenta 35
purple [0] 35
aqua [0] 36
cyan 36
white 37
bgblack 40
bgred 41
bggreen 42
bgyellow 43
bgblue 44
bgmagenta 45
bgpurple [0] 45
bgaqua [0] 46
bgcyan 46
bgwhite 47
bgbblack 100
bgbred 101
bgbgreen 102
bgbyellow 103
bgbblue 104
bgbmagenta 105
bgbpurple [0] 105
bgbaqua [0] 106
bgbcyan 106
bgbwhite 107
[0](1, 2, 3, 4, 5, 6, 7, 8) A custom color name.
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
vt100-colorprint-2.0.tar.gz (7.0 kB) Copy SHA256 Checksum SHA256 Source May 24, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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