=========================================================
                  generic colouriser

Radovan Garabik  http://www.fmph.uniba.sk/~garabik/
       <garabik@melkor.dnp.fmph.uniba.sk>

=========================================================

Being overflooded with different logfile colo(u)?ri(s|z)ers,
colortails, gccolors, colormakes and similar programs for making 
text files or outputs of different programs more readable by 
inserting ansi colour into them, I decided to write my 
very own colouriser, eventually providing the functions of all 
those others.

Two programs are provided: grc and grcat
The main is grcat, which acts as a filter, i.e. taking standard 
input, colourising it and writing to standard output.

grcat takes as a parameter the name of configuration file.

Directories  ~/.grc/, /usr/local/share/grc/, /usr/share/grc/ are searched
for the file (in this order). If the file is not found, it is assumed to be
an absolute path of a configuration file located elsewhere.

Format of configuration file: each entry consists of 3 lines, between
entries there can be any number of empty lines or lines beginning with #
(comments)

First line is regular expression, second line is colour the matched
expression is coloured with, third line is one of words: once, more, or
stop

 once means that if the regexp is matched, its first occurrence is coloured
and the program will continue with other regexp's.

 more means that if there are multiple matches of the regexp in one line,
all of them will be coloured.

 stop means that the regexp will be coloured and program will move to the
next line (i.e. ignoring other regexp's) 

example:

# this is probably a pathname
/[\w/\.]+
green
more

this will match /usr/bin, /usr/local/bin/, /etc/init.d/syslogd and similar
strings and paint it with green.

Typical usage:

grcat conf.log < /var/log/syslog
/usr/sbin/traceroute www.linux.org | grcat conf.traceroute
grcat conf.esperanto < Fundamento.txt  | less -r

To facilitate the use, command grc act as frontend for grcat, automatically 
choosing the configuration files.

grc will execute command command with optional parameters piping its stdout
into grcat.

Configuration file for grcat is determined by /etc/grc.conf or 
~/.grc/grc.conf file.

Format of /etc/grc.conf or ~/.grc/grc.conf: each entry consists of 2 lines,
between entries there can be any number of empty lines or lines beginning
with # (comments)

First line is regular expression, second line the name of configuration
file for grcat.

Configuration file after the first regular expression matching the rest of
line after grc will be passed to grcat as its configuration file

For example, if you have 

# log file
\b\w+\b.*log\b
conf.log

# traceroute command
(^|[/\w\.]+/)traceroute\s
conf.traceroute

in your /etc/grc.conf, then typing grc cat /var/log/syslog will use 
conf.log to colourise the output,
grc /usr/sbin/traceroute www.linux.org will use conf.traceroute

Miscellaneous remarks:
	Currently the program is in pre-alpha state. It works, but its function is 
	skeletal and there are only a few examples of configuration files 
	available. (I am looking for configuration files... if you write one, send 
	it to me, if possible). 
	It is possible that the configuration file format will change in the 
	future.

	You should get yourself familiar with regular expressions. Good reading is 
	at http://www.python.org/doc/howto/regex/regex.html

	The program is not yet optimized for speed. There are places that can 
	give a big boost if optimized. This is planned for future versions.

	Regular expressions are handled by python, it means that they may be
	slightly different from those you know from perl or grep. It's not my 
	fault in that case.

