Colorifer is set of utilities to
color output of other processes, e.g. command line utilites or
compilers. These programs make output more readable using different
color for the significant pieces of the text. For example, you can use
it to replace the color-gcc script or to colorize system logs. You only
need to create new config - set of the patterns (regular expressions)
and colors you want.
Colorifer project is divided into two parts:
- colorifer - main engine
- color-gcc - set of config
files to emulate functionality of colorgcc
script
Utilities
CSed
is a color stream editor. It works like sed, but don't edit stream and
made color
substitutions instead. This is a simple filter, you can use to colorize
output of any program.
Csed supports all sed like address types: '/REGEX/', 'NUMBER',
'FIRST~SEP', 'START,STOP', 'START,+NUMBER', 'START,~NUMBER'
You can also append '!' character to the end of an address
specification to negate the sense of the match.
To colorize whole string use
'[address]
p color[,attribute]' command with address specification,
You can also use
's/REGEX/color[,attribute]/'
command to colorize multiple substrings.
For example:
$echo "test1:test2"|csed
'/([a-z0-9]+):/ p blue'
test1:test2
See screenshot
here.
CSed is also an interesting for learning sed, and regular expressions.
Colorifer
is a wrapper to run program and colorize it's output.
It works like
"some-program
2>&1|([ -f some-file] && csed -f some-file)"
command, but also return exit code of program and don't mix stdout and
stderr of the program. Colorifer's config is a set of Csed's commands.
Pcolorize
is a srcipt to setup colorifer wrapper. For example, if you want to
colorize gcc and g++ type:
$pcolorize gcc g++
This script will creates two shell scripts in you $HOME/bin directory.
How to colorize ps system
utility?
$ cat>~/bin/ps
<<EOF
> #!/bin/sh
> PATH=/bin:/usr/bin
> ps "\$@" |csed '1 p
yellow,bold' 's/^[[:space:]a-z]*(\d+)/red/'
> EOF
$ chmod +x ~/bin/ps
$ ps
PID TTY TIME CMD
6826 pts/1 00:00:00 bash
10254 pts/1 00:00:00 ps
10255 pts/1 00:00:00 ps
10256 pts/1 00:00:00 csed
Download latest version of colorifer
here.
Colorifer is written by Stanislav Ievlev and Alexey
Voinov
Hosted by