Scroll to navigation

COLORIZE(1) User Commands COLORIZE(1)


colorize - colorize text on terminal with ANSI escape sequences


colorize [option]... (foreground) [-|file]

colorize [option]... (foreground)/(background) [-|file]

colorize --clean[-all] [-|file]

colorize -hV


Colorizes text read from standard input stream or file by using ANSI escape sequences (and also vice versa, i.e. cleaning text from sequences) and prints resulting output to the terminal.

When colorizing text, (foreground) and eventually (background) may be either one of following color values: none, black, red, green, yellow, blue, magenta, cyan, white, default or random. First character of color name in upper case denotes increased intensity, whereas for lower case colors will be of normal intensity. If "none" is chosen, no escape sequences will be emitted.

Color escape sequences are added per each line, hence colored lines can be safely extracted.

When de-colorizing text, --clean omits color escape sequences which were emitted by colorize (see NOTES for list), whereas --clean-all omits all valid ones. If in doubt, consider using --clean-all.


set attributes by name
Attributes: bold, underscore, blink, reverse and concealed.
clean text from color escape sequences emitted by colorize
clean text from all valid color escape sequences
alternate configuration file location
text color to be excluded when selecting a random foreground color
omit printing color escape sequences for empty lines
show help screen and exit
display version data and exit


user configuration file

If the aforementioned file exists, it is read, parsed and processed prior to handling the command-line options. Command-line options override configuration values, but are currently not capable of unsetting them. If unsetting is desired, comment them out or remove them.

Sample configuration file
# ~/.colorize.conf
attr = bold,underscore
color = magenta # favorite one
exclude-random = black
omit-color-empty = yes

Configurable options and values
attr             (values same as command-line option)
color            (value  same as command-line colors)
exclude-random   (value  same as command-line option)
omit-color-empty (yes/no)

Each line ought to start with a name of an option, followed by = and an optional value. Leaving the value blank, unsets the option.

Whitespace is allowed before the option name, after the option name, before the option value and after the option value.

Comments may be placed before or after the option is set. Everything following the '#' sign is treated as being commented out.


The list of color escape sequence codes being emitted and omitted is as follows:

  • 30-37,39 (foreground colors)
  • 1-9;30-37,39 (foreground colors with attributes)
  • 40-47,49 (background colors)
  • 0 (reset)


$ colorize green /etc/motd
Print file /etc/motd with green as foreground color
$ colorize green/black /etc/motd
Print file /etc/motd with green as foreground and black as background color
$ colorize green /etc/motd | colorize --clean
Print input from stdin with color escape sequences omitted
$ git log -1 -p --color | colorize --clean-all
Print input from stdin with all color escape sequences omitted
$ colorize --attr=bold green /etc/motd
Print file /etc/motd with bold green as foreground color


Steven Schubiger <>

2019-09-01 colorize v0.65