colorize - colorize text on terminal with ANSI escape sequences
colorize [option]... (foreground) [-|file]
colorize [option]... (foreground)/(background) [-|file]
colorize --clean[-all] [-|file]
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
- clean text from color escape sequences emitted by colorize
- clean text from all valid color escape sequences
- -c, --config=PATH
- alternate configuration file location
- text color to be excluded when selecting a random foreground color
- omit printing color escape sequences for empty lines
- -h, --help
- show help screen and exit
- -V, --version
- display version data and exit
- user configuration file
# ~/.colorize.conf attr = bold,underscore color = magenta # favorite one exclude-random = black omit-color-empty = yes
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)
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 <firstname.lastname@example.org>