grc-1.5/0000755000000000000000000000000012201443337007017 5ustar grc-1.5/grc0000755000000000000000000000750012171250021007512 0ustar #! /usr/bin/python import os, re, string, sys, getopt, signal def version(): print ("Generic Colouriser 1.5") sys.exit() def help(): print("""Generic Colouriser 1.5 grc [options] command [args] Options:") -e --stderr redirect stderr. If this option is selected, do not automatically redirect stdout -s --stdout redirect stdout, even if -e is selected -c name --config=name use name as configuration file for grcat --colour=word word is one of: on, off, auto """) sys.exit() def catch_signal(signum, frame): "catch signal sent to grc and forward it to the original application" global pidp try: os.kill(pidp, signum) except OSError: # if the subprocess already died pass try: optlist, args = getopt.getopt(sys.argv[1:], "sec:", ["stdout", "stderr", "config=", "colour="] ) except: help() if not args: help() stdoutf = 0 stderrf = 0 # configure file for grcat cfile = "" colour = 1 for i in optlist: if i[0] in ["--stderr", "-e"]: stderrf = 1 elif i[0] in ["--stdout", "-s"]: stdoutf = 1 elif i[0] in ["--config", "-c"]: cfile = i[1] elif i[0] == "--colour": if i[1] == "on": colour = 1 elif i[1] == "off": colour = 0 elif i[1] == "auto": colour = sys.stdout.isatty() else: help() stdoutff = 1 stderrff = 0 if stderrf == 1: stdoutff = 0 stderrff = 1 if stdoutf == 1: stdoutff = 1 conffile = None if cfile == "": home = [] if 'HOME' in os.environ: home = [os.environ['HOME']+"/.grc/grc.conf"] conffilenames = home + ["/etc/grc.conf"] for i in conffilenames: if os.path.isfile(i): conffile = i break regexplist = [] if conffile: f = open(conffile, "r") while 1: l = f.readline() if l == "": break if l[0] == "#" or l[0] == '\012': continue regexp = l.strip() if re.search(regexp, ' '.join(args)): cfile = f.readline().strip() break signal.signal(signal.SIGINT, catch_signal) if cfile != "" and colour: if stdoutff: choo, chio = os.pipe() if stderrff: choe, chie = os.pipe() pidp = os.fork() if pidp == 0: # child if stdoutff: os.dup2(chio, 1) os.close(choo) os.close(chio) if stderrff: os.dup2(chie, 2) os.close(choe) os.close(chie) os.execvp(args[0], args) if stdoutff: pido = os.fork() if pido == 0: # child os.dup2(choo, 0) os.close(choo) os.close(chio) if stderrff: os.close(choe) os.close(chie) os.execvp("grcat", ["grcat", cfile]) if stderrff: pide = os.fork() if pide == 0: # child os.dup2(choe, 0) os.dup2(2, 1) os.close(choe) os.close(chie) if stdoutff: os.close(choo) os.close(chio) os.execvp("grcat", ["grcat", cfile]) try: status = os.waitpid(pidp, 0)[1] except OSError: # interrupted system call status = None pass # this is probably not correct if stderrff: os.close(chie) os.waitpid(pide, 0) os.close(choe) if stdoutff: os.close(chio) os.waitpid(pido, 0) os.close(choo) sys.exit(status and os.WEXITSTATUS(status)) else: pidp = os.fork() if pidp == 0: os.execvp(args[0], args) try: status = os.wait()[1] except OSError: # interrupted system call status = None pass # this is probably not correct sys.exit(status and os.WEXITSTATUS(status)) grc-1.5/TODO0000644000000000000000000000011212164041041007473 0ustar optimize for speed handle ^C intelligently - almost done (multiline mode) grc-1.5/conf.ls0000644000000000000000000000174012171247774010323 0ustar # size regexp=(\s|^)\d+([.,]\d+)?\s?([kKMG][bB]|[bB]|[kKMG])(?=[\s,]|$) colours=yellow ======= # time regexp=(\s|^)\d+(:\d+)+(?=[\s,]|$) colours=bold green ======= # mounth regexp=\s[a-z]{3}\s colours=yellow ======= #regexp=(?<=\d):(?=\d) #colours=bold yellow #======= # root regexp=root|wheel(?=\s|$) colours=bold red ======= # -rwxrwxrwx regexp=(-|([bcCdDlMnpPs?]))(?=[-r][-w][-xsStT][-r][-w][-xsStT][-r][-w][-xsStT]) colours=unchanged,unchanged,bold blue ======= regexp=(?<=[-bcCdDlMnpPs?])(-|(r))(-|(w))(-|([xsStT]))(?=[-r][-w][-xsStT][-r][-w][-xsStT]) colours=unchanged,unchanged,bold green,unchanged,bold green,unchanged,bold green ======= regexp=(?<=[-bcCdDlMnpPs?][-r][-w][-xsStT])(-|(r))(-|(w))(-|([xsStT]))(?=[-r][-w][-xsStT]) colours=unchanged,unchanged,bold yellow,unchanged,bold yellow,unchanged,bold yellow ======= regexp=(?<=[-bcCdDlMnpPs?][-r][-w][-xsStT][-r][-w][-xsStT])(-|(r))(-|(w))(-|([xsStT])) colours=unchanged,unchanged,bold red,unchanged,bold red,unchanged,bold red grc-1.5/conf.ps0000644000000000000000000000146112173240730010312 0ustar # /full/path regexp=(\s|^)/[-\w\d.]+/[-\w\d./]+ colours=white ======= # CAPS LINE regexp=^[A-Z\s%]*([A-Z]{3})[A-Z\s%]*$ colours=underline ======= # Capd Line regexp=^([A-Z][-a-z0-9]+(\s+|$)){3,}$ colours=underline ======= # VMSTAT regexp=(\s|^)\d+([.,]\d+)?(?=[\s,]|$) colours=bold green ======= # n.n.n regexp=(\s|^)\d+\.\d+\.\d+(?=[\s,]|$) colours=bold cyan ======= # text: regexp=^([-a-z0-9]+):\s colours=unchanged,yellow ======= # -options regexp=(?<=\s)-[\w\d]+(?=\s|$) colours=yellow ======= # --long-option= regexp=(?<=\s)--[-\w\d]+[\w\d](?==|\s|$)(=?) colours=cyan,white ======= # [text] regexp=\[[-\w\d:/]+\] colours=cyan ======= # root regexp=root|wheel(?=\s|$) colours=red ======= # pts regexp=(\s|^)pts/\d+(?=[^\w\d]|$) colours=bold yellow ======= # tty regexp=(\s|^)tty\d+(?=[^\w\d]|$) colours=bold cyan grc-1.5/contrib/0000755000000000000000000000000012164041044010454 5ustar grc-1.5/contrib/conf.efingerd0000644000000000000000000000077112164041044013113 0ustar # contributed by Daniel Kollár # @host regexp=@\w+[\w\-\.]+\w+ colours=magenta count=once ====== # who fingers regexp=(\s\w+[\w\-\.]+)(?=@) colours=bold magenta count=once ====== # user null fingers regexp=\(null\) colours=green count=once ====== # who's fingered regexp=(\s\d\d\d\d\s)(\w+[\w\-\.]+\s(?=fingered)) colours=bold yellow count=once ====== # date and time regexp=^(...)(\s...\s.\d \d\d:\d\d:\d\d)(\s...\s\d\d\d\d\s) colours=green, green, bold green, green count=once grc-1.5/contrib/nmh-in-color/0000755000000000000000000000000012164041044012756 5ustar grc-1.5/contrib/nmh-in-color/configs/0000755000000000000000000000000012164041046014410 5ustar grc-1.5/contrib/nmh-in-color/configs/conf.flists0000644000000000000000000000075712164041046016574 0ustar #--------------------------------------------------------------------------- # $Id: conf.flists,v 1.5 2001/01/19 03:04:38 mig Exp mig $ #--------------------------------------------------------------------------- # GRC config file for use with nmh(1) command flists(1). #--------------------------------------------------------------------------- # Unread messages: regexp=.*has\s+([0-9]+[0-9]|[1-9])\sin.* colours=yellow count=more - # Current folder: regexp=.*\+\s+.* colours=green count=once grc-1.5/contrib/nmh-in-color/configs/mhl.headers0000644000000000000000000000105512164041046016526 0ustar ; mhl.headers ; ; Slighly modified version of the default mhl.headers file included with ; nmh-1.0.x. See the comments at the top of mhl.format for more details. ; ; Format file for displaying headers in ; MIME messages. mhn calls the mhlproc with this ; filter to display message header. ; overflowtext="*** ",overflowoffset=5 leftadjust,compwidth=9 ignores=msgid,message-id,received,content-type,content-transfer-encoding,content-id Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>" To: cc: From:decode Subject:decode : extras:nocomponent : grc-1.5/contrib/nmh-in-color/configs/conf.mail0000644000000000000000000000773112164041046016211 0ustar #--------------------------------------------------------------------------- # $Id: conf.mail,v 3.3 2001/01/19 03:10:13 mig Exp mig $ #------------------------------------------------------------------------- # This configuration file is suitable for displaying mail files. # Such as when mail is read with mh(1) or nmh(1). # # This version makes more use of the block count to avoid listing all of # the possible header lines... #------------------------------------------------------------------------- # The Date, will be green. #------------------------------------------------------------------------- regexp=^\s*(Date|Sent):.* colours=green count=stop - #------------------------------------------------------------------------- # The To, CC, BCC, and From, etc. lines will be green. #------------------------------------------------------------------------- regexp=^\s*((In-)?([Rr]eply-)?[Tt]o|From|Author|[BbFf]?[Cc][Cc]): colours=green count=more - #------------------------------------------------------------------------- # The Subject line will be red. #------------------------------------------------------------------------- regexp=^\s*Subject:.*$ colours=bold red count=stop - #------------------------------------------------------------------------- # Long lines: #------------------------------------------------------------------------- regexp=^\s{5}\*\*\*.*$ colours=previous count=previous - #------------------------------------------------------------------------- # Header lines added by nmh: #------------------------------------------------------------------------- regexp=^\s*Replied:.*$ colours=cyan count=more - #------------------------------------------------------------------------- # Other mail header lines will be yellow. #------------------------------------------------------------------------- regexp=^(([Xx]-{0,1}.*\S)|((Return-)?Path)|(MIME-{0,1}.*\S)):.*$ colours=yellow count=block - #------------------------------------------------------------------------- # Multi-line signatures: #------------------------------------------------------------------------- regexp=^-{1,3}\s{0,1}$ colours=red count=block - regexp=^={1,5}\s{0,1}$ colours=red count=block - regexp=^-=-\s{0,1}$ colours=red count=block - #------------------------------------------------------------------------- # This unblock applies to all of the block lines above: #------------------------------------------------------------------------- regexp=^\s{0,5}$ colours=default count=unblock - #--------------------------------------------------------------------------- # This will make most separating lines blue: #--------------------------------------------------------------------------- regexp=^.*([-=_!#$*<=>.:/|\\~`] *){7}.*$ colours=blue count=more - #------------------------------------------------------------------------- # Any quoted messages will show up in blue if quoted an odd number of times, # cyan if quoted an even number of times. The main message text will remain # unchanged. # # (I grabbed these regexp's from the vim-5.x mail.vim file.) #------------------------------------------------------------------------- regexp=^[ \t]*([A-Za-z]+>|[\]|}>#:]).*$ colours=blue count=more - regexp=^[ \t]*(([A-Za-z]+>|[\]|}>#:])[ \t]*){2}.*$ colours=cyan count=more - regexp=^[ \t]*(([A-Za-z]+>|[\]|}>#:])[ \t]*){3}.*$ colours=blue count=more - regexp=^[ \t]*(([A-Za-z]+>|[\]|}>#:])[ \t]*){4}.*$ colours=cyan count=more - regexp=^[ \t]*(([A-Za-z]+>|[\]|}>#:])[ \t]*){5}.*$ colours=blue count=more - regexp=^[ \t]*(([A-Za-z]+>|[\]|}>#:])[ \t]*){6}.*$ colours=cyan count=more - #------------------------------------------------------------------------- # Highlight URLs in magenta and email addresses in green: #------------------------------------------------------------------------- regexp=\b\S+@\S+\b colours=green count=more - regexp=mailto:\S+@\S+\b colours=green count=more - regexp=https?:\/\/\S+\b colours=magenta count=more - regexp=ftp:\/\/\S+\b colours=magenta count=more - regexp=file:\/\/\S+\b colours=magenta count=more grc-1.5/contrib/nmh-in-color/configs/conf.scan0000644000000000000000000000140712164041046016205 0ustar #--------------------------------------------------------------------------- # $Id: conf.scan,v 1.6 2001/01/20 00:01:32 mig Exp mig $ #--------------------------------------------------------------------------- # GRC config file for use with nmh(1) command scan(1). # # This file works well with the scan.unseen file provided with nmh(1). #--------------------------------------------------------------------------- # The header line: regexp=^FOLDER.* colours=green count=once - # Messages replied-to by me: regexp=^\s{0,3}\d{1,5}\s+-.* colours=cyan count=more - # Replies... regexp=\s+R[Ee]:\s+.* colours=blue count=more - # Unread messages: regexp=^\s{0,3}\d{1,5}\sU\s.{23} colours=yellow count=more - # Current message: regexp=^\s{0,3}\d{1,5}\+.* colours=green count=once grc-1.5/contrib/nmh-in-color/configs/bashrc-entries0000644000000000000000000000245712164041046017254 0ustar #---------------------------------------------------------------------- # This alias shows all my mail folders, highlighting (in yellow) # those which have new mail in them. #---------------------------------------------------------------------- alias flists="grc flists" #---------------------------------------------------------------------- # I use Procmail to sort my incoming mail into nmh folders, this alias # shows me only the folders that have new mail in them: #---------------------------------------------------------------------- alias fl="flists -seq unseen -noshowzero -recurse" #---------------------------------------------------------------------- # Since I use procmail(1), I don't use inc(1) much... #---------------------------------------------------------------------- alias inc="grc inc" #---------------------------------------------------------------------- # I like to have a header on the the scan(1) output so I know where I am. # Feel free to change any of the colors in the conf-* files... #---------------------------------------------------------------------- alias scan="grc scan -header" #---------------------------------------------------------------------- # Just a shortcut for the inbox: #---------------------------------------------------------------------- alias si="scan +inbox" grc-1.5/contrib/nmh-in-color/configs/mhl.body0000644000000000000000000000011412164041046016043 0ustar body:nocomponent,width=79,overflowtext="*** ",overflowoffset=5,noleftadjust grc-1.5/contrib/nmh-in-color/configs/rxvt-resources0000644000000000000000000000154112164041046017347 0ustar !-------------------------------------------------------------- ! These are the resource settings I use with rxvt(1), ! they were in place when the screenshots were generated. ! ! If you prefer your terminal windows with dark text on ! a light background, you'll have to tweak the colors here, as ! well as in the grc conf-* files. !----------------- ! Rxvt settings !----------------- Rxvt*background: black Rxvt*foreground: gray70 Rxvt*color4: #1e90ff Rxvt*color12: #63b8ff Rxvt*colorBD: #63b8ff Rxvt*colorUL: #00ffff ! !-------------------------------------------------------------- ! The following settings have a similar effect on ! xterm(1). !----------------- ! Xterm settings !----------------- XTerm*background: black XTerm*foreground: gray70 XTerm*colorBDMode: on XTerm*color4: #1e90ff XTerm*color12: #63b8ff XTerm*colorBD: #63b8ff XTerm*colorUL: #00ffff grc-1.5/contrib/nmh-in-color/configs/conf.inc0000644000000000000000000000073112164041046016031 0ustar #--------------------------------------------------------------------------- # $Id: conf.inc,v 1.5 2001/01/20 00:00:57 mig Exp mig $ #--------------------------------------------------------------------------- # GRC config file for use with nmh(1) command inc(1). #--------------------------------------------------------------------------- # Replies... regexp=\s+R[Ee]:\s+.* colours=blue count=more - # Current message: regexp=^\s{0,3}\d{1,5}\+.* colours=green count=once grc-1.5/contrib/nmh-in-color/configs/mhl.format0000644000000000000000000000124012164041046016377 0ustar ; mhl.format ; ; This is a slighly modified version of the default mhl.format file included ; with nmh-1.0.x. I've added "width=79,overflowtext='*** '" to the "body" ; line at the bottom. I've also made the the overflowtext string "*** " ; instead of the default "***" to improve readability. ; ; Miguel Gualdron (July 2000). ; : overflowtext="*** ",overflowoffset=5 leftadjust,compwidth=9 ignores=msgid,message-id,received,content-type,content-transfer-encoding,content-id Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>" To: cc: From:decode Subject:decode : extras:nocomponent : body:nocomponent,width=79,overflowtext="*** ",overflowoffset=5,noleftadjust grc-1.5/contrib/nmh-in-color/configs/grc.conf-entries0000644000000000000000000000041712164041046017503 0ustar # # Add these entries to the /etc/grc.conf file, so grc does the right thing # when the scan, flists, and inc commands are used. # # scan command (^|[/\w\.]+/)scan\b conf.scan # flists command (^|[/\w\.]+/)flists\b conf.flists # inc command (^|[/\w\.]+/)inc\b conf.inc grc-1.5/contrib/nmh-in-color/configs/mh_profile-entries0000644000000000000000000000061112164041046020124 0ustar #: #: The .mh_profile entries listed below may be useful when using #: nmh with grc/grcat. #: moreproc: viewmail Unseen-Sequence: unseen scan: -form scan.unseen comp: -editor vimail repl: -annotate -nocc all -fcc sent-mail -filter reply.filter -editor vimail forw: -editor forwedit -format forwedit: -editor vimail flists: -recurse mhshow-show-text/html: lynx -dump -force_html '%f' |viewmail grc-1.5/contrib/nmh-in-color/README0000644000000000000000000000614612164041044013645 0ustar -------------- COLORIZING nmh -------------- I've been using nmh on Linux for a few years now, it is a powerful mail handling system maintained by a team of volunteers. The latest version can be found at: http://www.mhost.com/nmh/ A few months ago I discovered grc, a very cool "generic colouriser", written by Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/grc.html Since I'm hooked on nmh, I decided to use grc with it. Here's a list of the files needed: The latest version of these files can be found at: http://users.anet.com/~mig/nmh-in-color/nmh-in-color.tar.gz configs/ bashrc-entries Example alias entries for a ~/.bashrc file. conf.flists grc config for flists command. conf.inc grc config for inc command. conf.mail grc config for show command. conf.scan grc config for scan command. grc.conf-entries sample entries for use in grc.conf mh_profile-entries sample entries for use in ~/.mh_profile mhl.body sample format file for MIME message body mhl.format sample format file for show command mhl.headers sample format file for MIME message headers rxvt-resources rxvt settings from ~/.Xdefaults used for the screenshots scripts/ viewmail Script for viewing colorized e-mail. vimail Script to call vim in mail-syntax mode. ------------ INSTALLATION ------------ Grab nmh-1.0.x.tar.gz, and grc_0.x.tar.gz from the websites above. Read the documentation included with the packages and install them. Grc requires a Python interpreter. I tested with grc_0.81 and Python-1.5.1. Copy the conf.* files to /usr/share/grc/ or /usr/local/share/grc/, depending on how grc was installed. Copy viewmail and vimail somewhere in your path, like ~/bin/. Note vimail does not use grc, but makes use of vim-5.x syntax-highlighting. You may have to modify the path to the syntax description files given in the script to match your system. If you only want to colorize email-viewing, or you don't use vim to compose messages, don't install vimail. Add the contents of bashrc-entries to your ~/.bashrc, and the contents of mh_profile-entries to your ~/.mh_profile (look these over first, some of these profile entries are just my personal preference). Also, add grc.conf-entries to /etc/grc.conf. I recommend the use of rxvt (http://www.rxvt.org). I've included the settings from my .Xdefaults file in rxvt-resources (don't forget to do a xrdb -load .Xdefaults after you put these in place). -------- COMMENTS -------- The color-scheme I've used in the conf.* files is optimized for light text on a dark background. Please feel free to make modifications. Enjoy! Miguel Gualdron (August 2000) mig@anet.com http://users.anet.com/~mig/nmh-in-color #--------------------------------------------------------------------------- # README file for nmh-in-color.tar.gz # $Id: README,v 1.7 2001/01/19 03:32:30 mig Exp mig $ #--------------------------------------------------------------------------- grc-1.5/contrib/nmh-in-color/scripts/0000755000000000000000000000000012164041046014447 5ustar grc-1.5/contrib/nmh-in-color/scripts/vimail0000755000000000000000000000105712164041046015661 0ustar #!/bin/sh # #--------------------------------------------------------------------------- # $Id: vimail,v 1.3 2000/08/19 00:25:17 mig Exp mig $ #--------------------------------------------------------------------------- # Script Name: vimail # Purpose: Short script to edit mail from nmh(1) # This script makes use if vim-5.x syntax highlighting. # #--------------------------------------------------------------------------- if [ $# = 0 ]; then vi +'so $VIM/syntax/mail.vim' - else vi +'so $VIM/syntax/mail.vim' $* fi grc-1.5/contrib/nmh-in-color/scripts/viewmail0000755000000000000000000000201012164041046016203 0ustar #!/bin/sh # #--------------------------------------------------------------------------- # $Id: viewmail,v 1.4 2000/08/19 00:23:32 mig Exp mig $ #---------------------------------------------------------------------- # Script Name: viewmail # Purpose: Short script to page through and colorize email. # #---------------------------------------------------------------------- #--------------------------------------------------------------------------- # If we're sending output to a terminal, then colorize it, # otherwise, just cat it (...in case we're piping to lpr, etc.). # # Assume the input comes from STDIN. If we get command-line arguments, # then we assume they're filenames, and cat them each in turn. #--------------------------------------------------------------------------- if [ -t 1 ]; then if [ $# -eq 0 ]; then grcat conf.mail | less -r else for _arg in $* do grcat conf.mail < $_arg | less -r done fi else if [ $# -eq 0 ]; then cat else for _arg in $* do cat $_arg done fi fi grc-1.5/contrib/wrap-ccache0000755000000000000000000000077712164041044012572 0ustar #!/bin/sh # by Alexey Galakhov wd="`dirname $0`" ccache="`which ccache`" grc="`which grc`" grconf="conf.gcc" if [ "`basename $1`" = "configure" ]; then ccache="" grconf="conf.configure" fi gropts="" if perl -e 'use POSIX "isatty"; exit !isatty(1);'; then gropts="$gropts --stdout" fi if perl -e 'use POSIX "isatty"; exit !isatty(2);'; then gropts="$gropts --stderr" fi if [ ! -z "$grc" -a ! -z "$gropts" ]; then grc="$grc -s -e -c $wd/$grconf" else grc="" fi exec $grc $ccache "$@" grc-1.5/grc.spec.old0000644000000000000000000000245112164041041011217 0ustar # Note that this is NOT a relocatable package %define ver 1.0 %define rel 1 %define prefix /usr %define confdir /etc Summary: Generic Colouriser Name: grc Version: %ver Release: %rel Copyright: GPL Group: Console/Utilities Source: grc_%{PACKAGE_VERSION}.tar.gz URL: http://melkor.dnp.fmph.uniba.sk/~garabik/grc.html BuildRoot: %{_tmppath}/grc-%{PACKAGE_VERSION}-root Packager: Christian Zuckschwerdt %description Generic Colouriser is yet another colouriser for beautifying your logfiles or output of commands. Authors: -------- Radovan Garabik %prep %setup %install rm -rf $RPM_BUILD_ROOT install -d -m 755 $RPM_BUILD_ROOT%{prefix}/bin install -m 755 grc $RPM_BUILD_ROOT%{prefix}/bin install -m 755 grcat $RPM_BUILD_ROOT%{prefix}/bin install -d -m 755 $RPM_BUILD_ROOT%{prefix}/share/grc install -m 644 conf.* $RPM_BUILD_ROOT%{prefix}/share/grc install -d -m 755 $RPM_BUILD_ROOT%{confdir} install -m 755 grc.conf $RPM_BUILD_ROOT%{confdir} install -d -m 755 $RPM_BUILD_ROOT%{_mandir}/man1 install -m 644 *.1 $RPM_BUILD_ROOT%{_mandir}/man1 %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-, root, root) %doc CHANGES CREDITS README TODO Regexp.txt %{prefix}/bin/* %{prefix}/share/grc/* %doc %{_mandir}/man1/* %config /etc/* grc-1.5/conf.irclog0000644000000000000000000000071512164041041011142 0ustar # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=magenta ======= # *** regexp=\*\*\* colours=bold green ======= # +++ regexp=\+\+\+ colours=green ======= # mail address regexp=\S+\@[\w\-\.]+ colours=bold yellow ======= # Signoff regexp=Signoff colours=bold red ======= # Signon regexp=Signon colours=bold green ======= # everything in parentheses regexp=\(.+?\) colours=green count=more ======= # channel name regexp=\#[\w\-\.]+ colours=bold blue grc-1.5/grc.conf0000644000000000000000000000163012173241102010433 0ustar # anything to do with irc \b\w+\b.*irc.* conf.irclog # log file \b\w+\b.*log\b conf.log # configure command (^|[/\w\.]+/)?configure conf.configure # ping command (^|[/\w\.]+/)ping6?\s conf.ping # traceroute command (^|[/\w\.]+/)traceroute6?\s conf.traceroute # gcc command (^|[/\w\.]+/)g?cc\s conf.gcc # make command (^|[/\w\.]+/)g?make\s? conf.gcc # netstat command (^|[/\w\.]+/)netstat\s? conf.netstat # diff command (^|[/\w\.]+/)diff\s? conf.diff # wdiff command (^|[/\w\.]+/)wdiff\s? conf.wdiff # last command (^|[/\w\.]+/)last\s? conf.log # ldap tools (^|[/\w\.]+/)ldap conf.ldap # cvs command (^|[/\w\.]+/)cvs\s? conf.cvs # mount command (^|[/\w\.]+/)mount\s? conf.mount # mtr command (^|[/\w\.]+/)mtr\s? conf.mtr # ps command (^|[/\w\.]+/)ps\s? conf.ps # dig command (^|[/\w\.]+/)dig\s? conf.dig # ifconfig command (^|[/\w\.]+/)ifconfig\s? conf.ifconfig # ls command (^|[/\w\.]+/)ls\s? conf.ls grc-1.5/grc.spec0000644000000000000000000000267712164041041010454 0ustar # Note that this is NOT a relocatable package %define ver 1.0.8 %define rel 1 %define prefix /usr %define confdir /etc Summary: Generic Colouriser Name: grc Version: %ver Release: %rel License: GPL Group: Development/Tools Source: grc-%{PACKAGE_VERSION}.tar.gz URL: http://melkor.dnp.fmph.uniba.sk/~garabik/grc.html BuildRoot: %{_tmppath}/grc-%{PACKAGE_VERSION}-root Packager: Valerij Klein BuildArchitectures: noarch %description Generic Colouriser is yet another colouriser for beautifying your logfiles or output of commands. Authors: -------- Radovan Garabik %prep %setup %install rm -rf $RPM_BUILD_ROOT install -d -m 755 $RPM_BUILD_ROOT%{prefix}/bin install -m 755 grc $RPM_BUILD_ROOT%{prefix}/bin install -m 755 grcat $RPM_BUILD_ROOT%{prefix}/bin install -d -m 755 $RPM_BUILD_ROOT%{prefix}/share/grc install -m 644 conf.* $RPM_BUILD_ROOT%{prefix}/share/grc install -d -m 755 $RPM_BUILD_ROOT%{confdir} install -m 644 grc.conf $RPM_BUILD_ROOT%{confdir} install -d -m 755 $RPM_BUILD_ROOT%{_mandir}/man1 install -m 644 *.1 $RPM_BUILD_ROOT%{_mandir}/man1 %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-, root, root) %doc CHANGES CREDITS README TODO Regexp.txt %{prefix}/bin/* %{prefix}/share/grc/* %doc %{_mandir}/man1/* %config(noreplace) /etc/grc.conf %changelog * Fri Sep 01 2006 Valerij Klein 1.0.7-1 - Minor changes in SPEC grc-1.5/conf.mount20000644000000000000000000000022612173240730011112 0ustar # Intended for colouring 'mount' output # written by Emanuele Aina regexp=^(.*) on (.*) type (.*) \((.*)\) colours=default,green,yellow,blue,magenta grc-1.5/grc.10000644000000000000000000000270612164041041007653 0ustar .TH GRC 1 .SH NAME grc \- frontend for generic colouriser .BR grcat "(1) .SH SYNOPSIS .B grc .I [options] "command [args]" .SH DESCRIPTION .BR grc will execute command .I "command" with optional parameters .I "[args]" piping its stdout or stderr into .BR grcat ", with apropriate configuration file. Configuration file for .BR grc is determined by /etc/grc.conf file. Format of /etc/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 .BR grcat ". Configuration file after the first regular expression matching .I "command [args]" will be passed to .BR grcat as its configuration file .SH OPTIONS .TP .B \-\-help Show summary of options. .TP .B \-\-version Display version. .TP .B \-e \-\-stderr Redirect error output. Unless .B -s is selected as well, this cancels redirection of standard output via .BR grcat .TP .B \-s \-\-stdout Redirect standard output. Used to redirect standard output together with .B \-\-stderr option. .TP .B \-\-colour=x x is one of .I on .I off .I auto .B \-\-colour=on will colourise (default) .B \-\-colour=off will just execute .I command without colourising. .B \-\-colour=auto will test if standard output is a tty, and colourise only when it is. .SH SEE ALSO .BR grcat "(1) .SH AUTHOR Written by Radovan Garab\('ik grc-1.5/grcat0000755000000000000000000001565212171250021010046 0ustar #! /usr/bin/python import sys, os, string, re, signal, errno #some default definitions colours = { 'none' : "", 'default' : "\033[0m", 'bold' : "\033[1m", 'underline' : "\033[4m", 'blink' : "\033[5m", 'reverse' : "\033[7m", 'concealed' : "\033[8m", 'black' : "\033[30m", 'red' : "\033[31m", 'green' : "\033[32m", 'yellow' : "\033[33m", 'blue' : "\033[34m", 'magenta' : "\033[35m", 'cyan' : "\033[36m", 'white' : "\033[37m", 'on_black' : "\033[40m", 'on_red' : "\033[41m", 'on_green' : "\033[42m", 'on_yellow' : "\033[43m", 'on_blue' : "\033[44m", 'on_magenta' : "\033[45m", 'on_cyan' : "\033[46m", 'on_white' : "\033[47m", 'beep' : "\007", 'previous' : "prev", 'unchanged' : "unchanged", # non-standard attributes, supported by some terminals 'dark' : "\033[2m", 'italic' : "\033[3m", 'rapidblink' : "\033[6m", 'strikethrough': "\033[9m", } # ignore ctrl C - this is not ideal for standalone grcat, but # enables propagating SIGINT to the other subprocess in grc signal.signal(signal.SIGINT, signal.SIG_IGN) def add2list(clist, m, patterncolour): for group in range(0, len(m.groups()) +1): if group < len(patterncolour): clist.append((m.start(group), m.end(group), patterncolour[group])) else: clist.append((m.start(group), m.end(group), patterncolour[0])) def get_colour(x): if x in colours: return colours[x] elif len(x)>=2 and x[0]=='"' and x[-1]=='"': return eval(x) else: raise ValueError('Bad colour specified: '+x) home = [] conffile = None if 'HOME' in os.environ: home = [os.environ['HOME']+"/.grc/"] conffilepath = [""] + home + ["/usr/local/share/grc/", "/usr/share/grc/"] conffile_arg = sys.argv[1] # tentative conffile for i in conffilepath: if os.path.isfile(i+conffile_arg): conffile = i+conffile_arg break if not conffile: sys.stderr.write("config file [%s] not found\n" % sys.argv[1]) sys.exit(1) regexplist = [] f = open(conffile, "r") is_last = 0 split = str.split lower = str.lower letters = string.ascii_letters while not is_last: ll = {'count':"more"} while 1: l = f.readline() if l == "": is_last = 1 break if l[0] == "#" or l[0] == '\012': continue if not l[0] in letters: break keyword, value = split(l[:-1], "=", 1) keyword = lower(keyword) if not keyword in ["regexp", "colours", "count", "command", "skip"]: raise ValueError("Invalid keyword") ll[keyword] = value # Split string into one string per regex group # e.g. split "brown bold, red" into "brown bold" and # "red" #colstrings = [] #for colgroup in split(ll['colours'], ','): # colourlist = split(colgroup) # c = "" # for i in colourlist : # c = c + colours[i] # colstrings.append(c) # do not try to understand the optimized form below :-) if 'colours' in ll: colstrings = list( map( lambda colgroup: ''.join(map(lambda x: get_colour(x), split(colgroup))), split(ll['colours'], ',') ) ) ll['colours'] = colstrings cs = ll['count'] ll['regexp'] = re.compile(ll['regexp']).search regexplist.append(ll) prevcolour = colours['default'] prevcount = "more" blockflag = 0 freadline = sys.stdin.readline while 1: line = freadline() if line == "" : break line = line[:-1] clist = [] skip = 0 for pattern in regexplist: pos = 0 currcount = pattern['count'] while 1: m = pattern['regexp'](line, pos) if m: if 'colours' in pattern: if currcount == "block": blockflag = 1 blockcolour = pattern['colours'][0] currcount = "stop" break elif currcount == "unblock": blockflag = 0 blockcolour = colours['default'] currcount = "stop" add2list(clist, m, pattern['colours']) if currcount == "previous": currcount = prevcount if currcount == "stop": break if currcount == "more": prevcount = "more" pos = m.end(0) else: prevcount = "once" pos = len(line) if 'command' in pattern: os.system(pattern['command']) if 'colours' not in pattern: break if 'skip' in pattern: skip = pattern['skip'] in ("yes", "1", "true") if 'colours' not in pattern: break else: break if m and currcount == "stop": prevcount = "stop" break if len(clist) == 0: prevcolour = colours['default'] first_char = 0 last_char = 0 length_line = len(line) if blockflag == 0: cline = (length_line+1)*[colours['default']] for i in clist: # each position in the string has its own colour if i[2] == "prev": cline[i[0]:i[1]] = [colours['default']+prevcolour]*(i[1]-i[0]) elif i[2] != "unchanged": cline[i[0]:i[1]] = [colours['default']+i[2]]*(i[1]-i[0]) if i[0] == 0: first_char = 1 if i[2] != "prev": prevcolour = i[2] if i[1] == length_line: last_char = 1 if first_char == 0 or last_char == 0: prevcolour = colours['default'] else: cline = (length_line+1)*[blockcolour] nline = "" clineprev = "" if not skip: for i in range(len(line)): if cline[i] == clineprev: nline = nline + line[i] else: nline = nline + cline[i] + line[i] clineprev = cline[i] nline = nline + colours['default'] try: print(nline) except IOError as e: if e.errno == errno.EPIPE: break else: raise grc-1.5/conf.diff0000644000000000000000000000063612164041041010575 0ustar # new lines and filenames (unified diff) regexp=^\+(.*$) colours=bold green count=more ======= # removed lines and filenames (unified diff) regexp=^\-(--.+$|[^\-].*$|$) colours=bold red count=more ======== # new lines regexp=^\>([^\>].*|$) colours=bold green count=more ======= # removed lines regexp=^\<([^\<].*|$) colours=bold red count=more ======= # lines affected regexp=^@@ .* @@$ colours=magenta count=more grc-1.5/conf.ldap0000644000000000000000000000035312164041041010601 0ustar # Intended for colouring LDIF output (from ldap tools) # comments regexp=^#.* colours=green count=stop - # meta regexp=^(version|search|result): colours=red count=stop - # "attribute: value" pairs regexp=^.*?: colours=blue count=stop grc-1.5/conf.ping0000644000000000000000000000070012164041041010612 0ustar # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=magenta ======= # ipv6 number regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+ colours=magenta ======= # time regexp=\d+\.\d+\sms colours=green ======= # time regexp=\d+\sms colours=green ====== # time regexp=time= colours=yellow ======= # DUP regexp=DUP\! colours=red ======= # (,) regexp=\(|\) colours=yellow ======= # unknown host regexp=.+unknown\shost\s(.+) colours=red,bold red grc-1.5/README0000644000000000000000000002037612201442520007700 0ustar =================================================================== Generic Colouriser Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/software/grc.html garabik @ kassiopeia.juls.savba.sk =================================================================== For the impatient - try following commands: grc netstat grc ping hostname grc tail /var/log/syslog grc ps aux --------------- 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 control codes 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. Configuration file consists of entries, one per regexp, entries are separated with lines with first character non-alphanumeric (except #). Lines beginning with # or empty lines are ignored. Each entry consists of several lines. Each line has form: keyword=value where keyword is one of: regexp, colours, command, skip, count Only regexp is mandatory, but it does not have much sense by itself unless you specify at least a colour, skip or command keyword as well. regexp is the regular expression to match colours is the list of colours, separated by commas (you can specify only one colour), each colour per one regexp group specified in regexp. if you use special colour name "previous", colour of the previous line of text will be used (actually, if both the first and last character of the previous line are of different colour than the default one, colour of the first one will be used). Another special colour name "unchanged" will leave the colour unchanged, useful if you need some context for matching regular expression and you want to leave the colour of context unchanged. Yet another special name is an arbitrary string enclosed in straight quotes. This string will be inserted directly into the output in front of the matching expression. The string will be eval'ed, so you can use usual python escape sequences. This is useful on a 256-colour enabled xterm, where e.g. colours="\033[38;5;22m" will give you a dark green (inspired by Rutger Ovidius). Caveat: the string cannot contain a comma. This is due to my laziness :-) command is command to be executed when regexp matches. Its output will be mixed with normal stdout, use redirectors ( >/dev/null) if you want to suppress it. skip can be skip=yes, if that case the matched line is skipped (discarded from the output), or skip=no, when it is not skipped. Default (if you do not have skip keyword) is of course not skipped. count is one of words: once, more, stop, previous, block or unblock 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) previous means the count will be the same as for the previous line block marks a start of a multiline block of text, coloured with the same colour unblock, obviously, marks the end of such a block example: # this is probably a pathname regexp=/[\w/\.]+ colour=green count=more this will match /usr/bin, /usr/local/bin/, /etc/init.d/syslogd and similar strings and paint it with green. Another example: regexp=^-{1,2}\s{0,1}$ colours=red count=block - regexp=^\s{0,5}$ colours=default count=unblock this will turn all correctly formatted mail signatures red. Regular expressions are evaluated from top to bottom, this allows nested and overlapped expressions. (e.g. you colour everything inside parentheses with one colour, and if a following expression matches the text inside parentheses, it will be also coloured) 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 acts as frontend for grcat, automatically choosing the configuration files, so you can write: grc netstat grc ping hostname grc tail /var/log/syslog etc... 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: 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. 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. Colours are one of: none, default, bold, underline, blink, reverse, concealed, black, green, yellow, blue, magenta, cyan, white, on_black, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white beep on_red means that the background (instead of foreground) is painted with red etc... Additional colours can be: dark, italic, rapidblink, strikethrough. These are supported only on some terminals, so if you want to write portable configuration files, avoid uing them (idea by James Rowe). there can be more attributes per line (separated by space), e.g. # this is probably a pathname regexp=/[\w/\.]+ colours=bold blink green count=more will display pathnames in bold blinking green ----------- Python 3 compatibility: There is some preliminary python3 support, meaning that both grc and grcat will run under both python2 and python3. However, all the regular expressions are strings, and grcat works on string input (not bytes). Therefore it will miserably fail if fed input with invalid UTF-8 characters. ----------- Hint taken from logcoloriser README: To have your syslog show on your tty12 in colour, do: mkfifo /dev/grc replace (or copy and edit) the /etc/syslog.conf line *.info;mail.*;authpriv.*;kern.*;local1.* |/dev/xconsole with : *.info;mail.*;authpriv.*;kern.*;local1.* |/dev/grc and add to your syslog startup script : grcat conf.log < /dev/grc >/dev/tty12 & Well, simpler approach seems to be to use something like this in your system startup script, if you have GNU tail: tail --follow=name /var/log/syslog | grcat conf.log >/dev/tty12 or, if you have recent BSD tail: tail -F /var/log/syslog | grcat conf.log >/dev/tty12 grc-1.5/Regexp.txt0000644000000000000000000002606012164041041011010 0ustar Regular Expression Syntax (taken from python library reference) A regular expression (or RE) specifies a set of strings that matches it; the functions in this module let you check if a particular string matches a given regular expression (or if a given regular expression matches a particular string, which comes down to the same thing). Regular expressions can be concatenated to form new regular expressions; if A and B are both regular expressions, then AB is also an regular expression. If a string p matches A and another string q matches B, the string pq will match AB. Thus, complex expressions can easily be constructed from simpler primitive expressions like the ones described here. For details of the theory and implementation of regular expressions, consult the Friedl book referenced below, or almost any textbook about compiler construction. A brief explanation of the format of regular expressions follows. For further information and a gentler presentation, consult the Regular Expression HOWTO, accessible from http://www.python.org/doc/howto/. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. (In the rest of this section, we'll write RE's in this special style, usually without quotes, and strings to be matched 'in single quotes'.) Some characters, like "|" or "(", are special. Special characters either stand for classes of ordinary characters, or affect how the regular expressions around them are interpreted. The special characters are: "." (Dot.) In the default mode, this matches any character except a newline. If the DOTALL flag has been specified, this matches any character including a newline. "^" (Caret.) Matches the start of the string, and in MULTILINE mode also matches immediately after each newline. "$" Matches the end of the string, and in MULTILINE mode also matches before a newline. foo matches both 'foo' and 'foobar', while the regular expression foo$ matches only 'foo'. "*" Causes the resulting RE to match 0 or more repetitions of the preceding RE, as many repetitions as are possible. ab* will match 'a', 'ab', or 'a' followed by any number of 'b's. "+" Causes the resulting RE to match 1 or more repetitions of the preceding RE. ab+ will match 'a' followed by any non-zero number of 'b's; it will not match just 'a'. "?" Causes the resulting RE to match 0 or 1 repetitions of the preceding RE. ab? will match either 'a' or 'ab'. *?, +?, ?? The "*", "+", and "?" qualifiers are all greedy; they match as much text as possible. Sometimes this behaviour isn't desired; if the RE <.*> is matched against '

title

', it will match the entire string, and not just '

'. Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few characters as possible will be matched. Using .*? in the previous expression will match only '

'. {m,n} Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as many repetitions as possible. For example, a{3,5} will match from 3 to 5 "a" characters. Omitting n specifies an infinite upper bound; you can't omit m. {m,n}? Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as few repetitions as possible. This is the non-greedy version of the previous qualifier. For example, on the 6-character string 'aaaaaa', a{3,5} will match 5 "a" characters, while a{3,5}? will only match 3 characters. "\" Either escapes special characters (permitting you to match characters like "*", "?", and so forth), or signals a special sequence; special sequences are discussed below. If you're not using a raw string to express the pattern, remember that Python also uses the backslash as an escape sequence in string literals; if the escape sequence isn't recognized by Python's parser, the backslash and subsequent character are included in the resulting string. However, if Python would recognize the resulting sequence, the backslash should be repeated twice. This is complicated and hard to understand, so it's highly recommended that you use raw strings for all but the simplest expressions. [] Used to indicate a set of characters. Characters can be listed individually, or a range of characters can be indicated by giving two characters and separating them by a "-". Special characters are not active inside sets. For example, [akm$] will match any of the characters "a", "k", "m", or "$"; [a-z] will match any lowercase letter, and [a-zA-Z0-9] matches any letter or digit. Character classes such as \w or \S(defined below) are also acceptable inside a range. If you want to include a "]" or a "-" inside a set, precede it with a backslash, or place it as the first character. The pattern []] will match ']', for example. You can match the characters not within a range by complementing the set. This is indicated by including a "^" as the first character of the set; "^" elsewhere will simply match the "^" character. For example, [^5] will match any character except "5". "|" A|B, where A and B can be arbitrary REs, creates a regular expression that will match either A or B. This can be used inside groups (see below) as well. To match a literal "|", use \|, or enclose it inside a character class, as in [|]. (...) Matches whatever regular expression is inside the parentheses, and indicates the start and end of a group; the contents of a group can be retrieved after a match has been performed, and can be matched later in the string with the \number special sequence, described below. To match the literals "(" or "')", use \( or \), or enclose them inside a character class: [(] [)]. (?...) This is an extension notation (a "?" following a "(" is not meaningful otherwise). The first character after the "?" determines what the meaning and further syntax of the construct is. Extensions usually do not create a new group; (?P...) is the only exception to this rule. Following are the currently supported extensions. (?iLmsx) (One or more letters from the set "i", "L", "m", "s", "x".) The group matches the empty string; the letters set the corresponding flags (re.I, re.L, re.M, re.S, re.X) for the entire regular expression. This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the compile() function. (?:...) A non-grouping version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern. (?P...) Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. Group names must be valid Python identifiers. A symbolic group is also a numbered group, just as if the group were not named. So the group named 'id' in the example above can also be referenced as the numbered group 1. For example, if the pattern is (?P[a-zA-Z_]\w*), the group can be referenced by its name in arguments to methods of match objects, such as m.group('id')or m.end('id'), and also by name in pattern text (e.g. (?P=id)) and replacement text (e.g. \g). (?P=name) Matches whatever text was matched by the earlier group named name. (?#...) A comment; the contents of the parentheses are simply ignored. (?=...) Matches if ... matches next, but doesn't consume any of the string. This is called a lookahead assertion. For example, Isaac (?=Asimov) will match 'Isaac ' only if it's followed by 'Asimov'. (?!...) Matches if ... doesn't match next. This is a negative lookahead assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if it's not followed by 'Asimov'. The special sequences consist of "\" and a character from the list below. If the ordinary character is not on the list, then the resulting RE will match the second character. For example, \$ matches the character "$". \number Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, (.+) \1 matches 'the the' or '55 55', but not 'the end' (note the space after the group). This special sequence can only be used to match one of the first 99 groups. If the first digit of number is 0, or number is 3 octal digits long, it will not be interpreted as a group match, but as the character with octal value number. Inside the "[" and "]" of a character class, all numeric escapes are treated as characters. \A Matches only at the start of the string. \b Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric characters, so the end of a word is indicated by whitespace or a non-alphanumeric character. Inside a character range, \b represents the backspace character, for compatibility with Python's string literals. \B Matches the empty string, but only when it is not at the beginning or end of a word. \d Matches any decimal digit; this is equivalent to the set [0-9]. \D Matches any non-digit character; this is equivalent to the set [^0-9]. \s Matches any whitespace character; this is equivalent to the set [ \t\n\r\f\v]. \S Matches any non-whitespace character; this is equivalent to the set [^ \t\n\r\f\v]. \w When the LOCALE flag is not specified, matches any alphanumeric character; this is equivalent to the set [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus whatever characters are defined as letters for the current locale. \W When the LOCALE flag is not specified, matches any non-alphanumeric character; this is equivalent to the set [^a-zA-Z0-9_]. With LOCALE, it will match any character not in the set [0-9_], and not defined as a letter for the current locale. \Z Matches only at the end of the string. \\ Matches a literal backslash. grc-1.5/install.sh0000755000000000000000000000043112164041041011014 0ustar #!/bin/sh DESTDIR=$1 BINDIR=$DESTDIR/usr/bin LIBDIR=$DESTDIR/usr/share/grc MANDIR=$DESTDIR/usr/share/man/man1 CONFDIR=$DESTDIR/etc mkdir -p $BINDIR || true cp -fv grc grcat $BINDIR mkdir -p $LIBDIR || true cp -fv conf.* $LIBDIR mkdir -p $CONFDIR || true cp -fv grc.conf $CONFDIR grc-1.5/conf.ifconfig0000644000000000000000000000124212171247774011466 0ustar # ip regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=bold green ======= # hwaddr regexp=(\d|[a-f])+(\:(\d|[a-f])+)+ colours=yellow ======= # size regexp=\d+(\.\d+)?\s(T|G|M|K)iB colours=yellow ======= # interface regexp=(([a-z]{3}\d)|lo): colours=bold green ======= #ip disc regexp=(inet|netmask|broadcast) colours=cyan ======= #flags regexp=(?<=[,<])[^,]*(?=[,>]) colours=blue ======= # mtu regexp=mtu\s\d+ colours=green ======= #errors regexp=errors\s\d colours=red ======= regexp=dropped\s\d colours=white ======= regexp=overruns\s\d colours=green ======= regexp=frame\s\d colours=white ======= regexp=carrier\s\d colours=cyan ======= regexp=collisions\s\d colours=red grc-1.5/conf.traceroute0000644000000000000000000000111612164041041012034 0ustar # hostname regexp=\s\w+[\w\-\.]+\w+ colours=bold yellow count=once - # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=magenta - # ipv6 number regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+ colours=magenta - # time regexp=\d+\.?\d*(?=\sms) colours=green - # ms regexp=\bms\b colours=yellow - # DUP regexp=\bDUP colours=red - # !S, !A, !H (host unreachable), etc. regexp=\b\![AFGNPSTU] colours=red # just an example: #command=echo 'Network is down'| mail root - # ttl=...! regexp=ttl=\d+\! colours=cyan - # * regexp=\* colours=red - # parenthesis regexp=\(|\) colours=yellow grc-1.5/debian/0000755000000000000000000000000012201443337010241 5ustar grc-1.5/debian/dirs0000644000000000000000000000002612164041044011120 0ustar usr/bin usr/share/grc grc-1.5/debian/docs0000644000000000000000000000005012164041044011104 0ustar TODO README Regexp.txt CREDITS contrib/ grc-1.5/debian/control0000644000000000000000000000062012201443324011636 0ustar Source: grc Section: text Priority: optional Maintainer: Radovan Garabík Standards-Version: 3.7.2 Build-Depends: debhelper (>=4) Package: grc Architecture: all Depends: python (>=2.6) | python3 Description: generic colouriser for everything generic colouriser, can be used to colourise logfiles, output of commands, arbitrary text.... configured via regexp's. grc-1.5/debian/rules0000755000000000000000000000246712173241102011324 0ustar #!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 build: build-stamp build-stamp: dh_testdir # Add here commands to compile the package. #$(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp # Add here commands to clean up after the build process. #-$(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tmp. ./install.sh `pwd`/debian/grc touch install-stamp # Build architecture-dependent files here. binary-arch: build install # Build architecture-independent files here. binary-indep: build install # dh_testversion dh_testdir dh_testroot # dh_installdebconf dh_installdocs dh_installexamples dh_installmenu # dh_installemacsen # dh_installpam # dh_installinit dh_installcron dh_installman grc.1 grcat.1 dh_installinfo # dh_undocumented dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms # You may want to make some executables suid here. # dh_suidregister # dh_makeshlibs dh_installdeb # dh_perl dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install grc-1.5/debian/changelog0000644000000000000000000001566612201443233012124 0ustar grc (1.5) unstable; urgency=low * added configuration file for the 'mount' command (thanks to Emanuele Aina) * catch SIGPIPE in grcat (closes: #689705), thanks to Дмитрий Кацубо for pointing this out * add several configuration files (thanks to Dark Wizard) * preliminary python3 support (thanks to Dark Wizard and Andreas Niederl), as a consequence, grc requires at least python2.6 -- Radovan Garabík Sat, 10 Aug 2013 14:23:01 +0200 grc (1.4) unstable; urgency=low * fix grcat argument search path, thanks to Andrzej Polis and Алексей Галахов * added conf.configure, thanks to Алексей Галахов * IPv6 support for ping6 and traceroute6 -- Radovan Garabík Sat, 14 May 2011 14:39:43 +0200 grc (1.3) unstable; urgency=low * propagate CTRL+C properly to the command being executed (for i in range(100): print "I'll never use wildcard 'except:' again") * if grcat argument starts with ./, search in current working directory * fix unified diff configuration to include also single '-', thanks to Markus Klinik for noticing -- Radovan Garabík Wed, 8 Jul 2009 20:29:06 +0200 grc (1.2) unstable; urgency=low * properly redirect stderr, thanks to Алексей Галахов * fix several minor pylint warnings -- Radovan Garabík Thu, 14 May 2009 19:21:00 +0200 grc (1.1) unstable; urgency=low * added several non-standard escape attributes (thanks to James Rowe) -- Radovan Garabík Sat, 31 Mar 2007 21:25:02 +0200 grc (1.0.9) unstable; urgency=low * added configuration file for the cvs command (thanks to Andreas Niederl) * modify diff configuration file to colour the filenames as well (thanks to Andreas Niederl) -- Radovan Garabík Thu, 4 Jan 2007 20:45:12 +0100 grc (1.0.8) unstable; urgency=low * add the possibility to include arbitrary string as the colourifying sequence -- Radovan Garabík Mon, 11 Sep 2006 09:58:54 +0200 grc (1.0.7) unstable; urgency=low * do not use sys.maxint, it caused problems * improve ping conffile, thanks to Michael Kebe (closes: #378981) -- Radovan Garabík Sat, 22 Jul 2006 08:56:56 +0200 grc (1.0.6) unstable; urgency=low * applied patch that causes grcat to complain and exits when grcat can't find the config file (thanks to Tripp Lilley ) -- Radovan Garabík Tue, 4 Mar 2003 13:42:47 +0100 grc (1.0.5) unstable; urgency=low * add "unchanged" colour (thanks to Jehan Bing ) -- Radovan Garabik Tue, 4 Feb 2003 14:29:55 +0100 grc (1.0.4) unstable; urgency=low * do not require $HOME to be set (closes: #158316) -- Radovan Garabik Wed, 4 Sep 2002 13:44:41 +0200 grc (1.0.3) unstable; urgency=low * added configuration file for colourising diff outputs (thanks to Dr. Rafael Sepúlveda ) -- Radovan Garabik Sun, 18 Aug 2002 19:35:34 +0200 grc (1.0.2) unstable; urgency=low * package updated for new python version in debian * if grc is run without any arguments, display helpful message (closes: #108675) * do not include INSTALL in debian documentation (closes: #94053) -- Radovan Garabik Sun, 21 Oct 2001 14:43:11 +0200 grc (1.0.1) unstable; urgency=low * included rpm spec file, conf.ldap, modified grc.conf - all thanks to Christian Zuckschwerdt -- Radovan Garabik Wed, 28 Feb 2001 21:56:02 +0100 grc (1.0) unstable; urgency=low * moved Build-Depends where it belongs * OK, this seems pretty stable already.... first stable version :-) -- Radovan Garabik Fri, 23 Feb 2001 21:27:55 +0100 grc (0.999) unstable; urgency=low * grc terminates with the exit status of subprogram * my e-mail added to README file :-) * license changed -- Radovan Garabik Mon, 12 Feb 2001 18:01:24 +0100 grc (0.99) unstable; urgency=low * candidate for stable version * corrected two stupid bugs when using skip option (closes: #84007) * upgraded nmh-in-color, by Miguel Gualdron -- Radovan Garabik Tue, 30 Jan 2001 15:06:57 +0100 grc (0.9) unstable; urgency=low * grc catches ctrl C and propagates to subprocess (Closes: #81137) * added skip keyword to skip lines in output containing certain patterns -- Radovan Garabik Thu, 18 Jan 2001 10:12:38 +0100 grc (0.8.1) unstable; urgency=low * typo in manpages fixed, closes: #70498 -- Radovan Garabik Tue, 29 Aug 2000 14:20:14 +0200 grc (0.8) unstable; urgency=low * added patches from Miguel Gualdron for colourising multiline blocks of text and making current colour dependent on previous line -- Radovan Garabik Sun, 27 Aug 2000 09:47:17 +0200 grc (0.7) unstable; urgency=low * redirecting both stdout and stderr works I do not know what was the error, but I made it differently and it works :-) -- Radovan Garabik Tue, 23 May 2000 21:35:46 +0200 grc (0.6) unstable; urgency=low * rewritten grc to use fork() and exec() * introduce --colour= option, to colourise depending on stdout being a tty (closes #62365) -- Radovan Garabik Sun, 7 May 2000 19:42:30 +0200 grc (0.5) unstable; urgency=low * a bit of speed optimization * added a few (2) more configuration files * added debhelper to Build-Depends * upgraded Standards-Version -- Radovan Garabik Mon, 14 Feb 2000 12:23:29 +0100 grc (0.4) unstable; urgency=low * change of configuration file format * added use of different colours per different regexp groups * added execution of external commands if regexp matches -- Radovan Garabik Mon, 22 Nov 1999 19:13:05 +0100 grc (0.3) unstable; urgency=low * enable nested and overlaped regular expressions - this fixes a few display glitches -- Radovan Garabik Wed, 27 Oct 1999 22:32:58 +0200 grc (0.2) unstable; urgency=low * grc can redirect stderr as well * background and other attributes (blink, bold) can be changed too * documentation update -- Radovan Garabik Tue, 26 Oct 1999 18:02:28 +0200 grc (0.1) unstable; urgency=low * Initial Release. -- Radovan Garabik Thu, 14 Oct 1999 19:24:25 +0200 Local variables: mode: debian-changelog End: grc-1.5/debian/compat0000664000000000000000000000000212173240730011441 0ustar 9 grc-1.5/debian/README.Debian0000644000000000000000000000016112164041044012275 0ustar grc ---------------------- packaged as native package -- Radovan Garabík grc-1.5/debian/copyright0000644000000000000000000000171612164041044012176 0ustar This is grc, written and maintained by Radovan Garabík on Thu, 14 Oct 1999 19:24:25 +0200. The original source can be found at: http://kassiopeia.juls.savba.sk/~garabik/software/grc.html It is released under GPL: under Debian systems see /usr/share/common-licenses/GPL, with following additional condition: If you want to use, redistribute, modify, abuse and molest grc in any way, and you feel like it, you may add any clause to the license, as long as it does not put any additional responsibility for behaviour of this program at me and at least one of these conditions is met: - the resulting license fulfills Debian free software guidelines (http://www.debian.org/social_contract#guidelines) - Richard Stallman has nothing against the new license, neither against running grc with any version of python available at the time of adding the clause - the resulting license brings peace and happiness to the world grc-1.5/conf.dig0000644000000000000000000000061712171247774010452 0ustar #ipv6 regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+ colours=green ======= #time regexp=\s[0-9]{1,6}\s colours=red ======= #type regexp=[A-Z]{1,4} colours=cyan ======= #in regexp=(IN|CH) colours=yellow ======= #domain regexp=[a-z0-9-]+\. colours=magenta ======= #ip address regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=green ======= #comments regexp=^;;\s\w*\s*\w* colours=yellow #======= grc-1.5/conf.cvs0000644000000000000000000000042712164041041010456 0ustar # conflict regexp=^C .*$ colours=bold red count=more ====== # modified regexp=^M .*$ colours=bold blue count=more ====== # added regexp=^A .*$ colours=cyan count=more ====== # removed regexp=^R .*$ colours=cyan count=more ====== # unlisted regexp=^\? .*$ colours=bold count=more grc-1.5/conf.gcc0000644000000000000000000000123512164041041010415 0ustar # regexp=\bgcc\b colours=yellow count=more ......... # regexp=^[^:\s]*?:\d+: colours=bold magenta ......... regexp=^[^:\s]*?: colours=cyan count=once ......... # regexp=\`[A-Za-z0-9_():&*]+( const)?\' colours=magenta ......... # -O regexp=\-O\d colours=green ......... # -o regexp=\-o\s.+\b colours=yellow ......... # warning and error won't work, unless you redirect also # stderr to grcat # # warning regexp=warning:.* colours=white ......... regexp=warning: colours=bold yellow count=once ......... # error regexp=error:.* colours=bold white ......... regexp=error: colours=bold white on_red count=once ......... #note regexp=note: colours=bold cyan count=once grc-1.5/conf.log0000644000000000000000000000146112164041041010443 0ustar # this configuration file is suitable for displaying kernel log files # display this line in yellow and stop further processing regexp=.*last message repeated \d+ times$ colours=yellow count=stop ====== # this is date regexp=^... (\d| )\d \d\d:\d\d:\d\d(\s[\w\d]+?\s) colours=green, green, red count=once ====== # everything in parentheses regexp=\(.+?\) colours=green count=more ====== # everything in `' regexp=\`.+?\' colours=bold yellow count=more ====== # this is probably a pathname regexp=/[\w/\.]+ colours=bold green count=more ====== # name of process and pid regexp=([\w/\.\-]+)(\[\d+?\]) colours=bold blue, bold red count=more ====== # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=bold magenta count=more ====== # connect requires special attention regexp=connect colours=on_red count=more grc-1.5/conf.mtr0000644000000000000000000000035312171247774010506 0ustar #ip address regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=green ======= # % regexp=[0-9]{1,2}\.\d{1}% colours=yellow ======= # unknow host regexp=\?\?\? colours=red ======= # Packets/Pings regexp=(Packets|Pings) colours=bold green grc-1.5/conf.netstat0000644000000000000000000000223012164041041011337 0ustar # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=magenta ======= # hostname:service regexp=([\w\.\-]+):([\w\-]+)\b colours=yellow, bold green, bold yellow ======= # hostname:port regexp=([\w\.\-]+):(\d+)\b colours=yellow, bold green, bold red ======= # *:service regexp=(\*):([\w\-]+)\b colours=yellow, blue, bold yellow ======= # ipx hostname regexp=^IPX.*[\dABCDEF]+:[\dABCDEF]+ colours=green ======= # protocols regexp=(^tcp|^udp|^unix|^IPX|STREAM|DGRAM) colours=bold blue ======= # status regexp=FIN_WAIT.* colours=red ======= # status regexp=SYN.*? colours=bold red ======= # status regexp=LISTEN(ING)? colours=bold blue ======= # status regexp=TIME_WAIT colours=bold red ======= # status regexp=CLOS(E(_WAIT)?|ING) colours=red skip=yes ======= # status regexp=LAST_ACK colours=red ======= # status regexp=ESTAB.*?\b|CONNECTED colours=bold yellow ======= # status regexp=FREE colours=bold green ======= # status regexp=DISCONNECTING colours=red ======= # status regexp=CONNECTING colours=green ======= # status regexp=UNKNOWN colours=blink bold red ======= # status regexp=\[.*\] colours=green ======= # path regexp=(\@)[\dabcdef]+ colours=green, bold green grc-1.5/conf.esperanto0000644000000000000000000000141612164041041011662 0ustar # cxi tia dosiero estas treege nekompleta kaj nur mallonga ekzemplo # kial skribi regulojn por kolorigo de tekstoj # # substantivoj regexp=(?i)\b\w+(?=(o|oj|on|ojn)\b) colours=green %%%%%%% # sufiksoj de substantivoj regexp=(?i)o(|j|n|jn)\b colours=yellow %%%%%%% # verboj regexp=\b\w+(?=(?i)i|as|is|os|u)\b colours=magenta %%%%%%% # sufiksoj de verboj regexp=(?i)(i|as|is|os|u)\b colours=yellow %%%%%%% # adverboj regexp=(?i)\b\w+(?=e\b) colours=bold magenta %%%%%%% # sufiksoj de adverboj regexp=(?i)(e|aux)\b colours=yellow %%%%%%% # adjektivoj regexp=(?i)\b\w+(?=(a|aj|an|ajn)\b) colours=blue %%%%%%% # sufiksoj de adjektivoj regexp=(?i)a(j|n|jn)\b colours=yellow %%%%%%% # kelkaj kurtaj vortoj regexp=(?i)\b(de|en|kun|sen|la|pli|plej|plu)\b colours=bold yellow grc-1.5/conf.configure0000644000000000000000000000033212164041041011637 0ustar regexp=^checking colours=bold blue ......... regexp=\.\.\. .*$ colours=bold yellow ......... regexp=\.\.\. yes$ colours=bold cyan ......... regexp=\.\.\. no$ colours=bold red ......... regexp=\.\.\.[ ] colours=default grc-1.5/conf.mount0000644000000000000000000000050012173240730011023 0ustar #/full/path regexp=\s/[-\w\d.]+(\s|/[-\w\d./]+) colours=cyan ======= #filesystem regexp=^\w+\s colours=yellow ======= #type filesystem #regexp=(?<=type)\s* #colours=red #======= # /dev/sda regexp=^(/dev/)?[s]d[a-f][0-9]*(?=[^\w\d]|$) colours=bold green ======= #mount options regexp=(?<=[,(])[^,]*(?=[,)]) colours=green grc-1.5/grcat.10000644000000000000000000000427212164041041010200 0ustar .TH GRCAT 1 .SH NAME grcat \- read from standard input, colourise it and write to standard output .SH SYNOPSIS .B grcat .I "configuration" .SH DESCRIPTION .I "configuration" is a name of a 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. Configuration file consists of entries, one per regexp, entries are separated with lines with first character non-alphanumeric (except #). Lines beginning with # or empty lines are ignored. Each entry consists of several lines. Each line has form: .I keyword=value where keyword is one of: .BR regexp ", .BR colours ", .BR command ", .BR skip ", .BR count ". Only .BR regexp is mandatory, but it does not have much sense by itself unless you specify at least a .BR colour or .BR command keyword as well. .I regexp is the regular expression to match .I colours is the list of colours, separated by commas (you can specify only one colour), each colour per one regexp group specified in regexp. .I command is command to be executed when regexp matches. Its output will be mixed with normal stdout, use redirectors ( >/dev/null) if you want to supress it. .I skip can be either .BR yes ", or .BR no ", if yes, the matched line will be skipped and not displayed in output. Default is no. .I count is one of words: .BR once ", .BR more ", or .BR stop ". .BR once means that if the regexp is matched, its first occurrence is coloured and the program will continue with other regexp's. .BR more means that if there are multiple matches of the regexp in one line, all of them will be coloured. .BR stop means that the regexp will be coloured and program will move to the next line (i.e. ignoring other regexp's) Regular expressions are evaluated from top to bottom, this allows nested and overlapped expressions. (e.g. you colour everything inside parentheses with one colour, and if a following expression matches the text inside parentheses, it will be also coloured) .SH OPTIONS None so far. .SH SEE ALSO .BR grc "(1) .SH AUTHOR Written by Radovan Garab\('ik grc-1.5/conf.wdiff0000644000000000000000000000020412164041041010753 0ustar # new words regexp=\{\+.+\+\} colours=bold green count=more ======= # deleted words regexp=\[\-.+\-\] colours=bold green count=more grc-1.5/INSTALL0000644000000000000000000000166712164041041010054 0ustar =================================================================== Generic Colouriser Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/software/grc.html =================================================================== Requirenments: anything with python interpreter, with more or less work needed if it is not unix. If you have debian system with all necessary packages installed, type dpkg-buildpackage (or dpkg-buildpackage -rfakeroot) in the package's directory, then type dpkg -i ../grc*deb else: 1) copy conf.* files into /usr/share/grc/ or /usr/local/share/grc/, creating directories when needed 2) copy grc.conf into /etc/ 3) copy grc and grcat somewhere to your path 4) read the README and manual pages 5) modify /etc/grc.conf if you feel like it there is a small shell script called install.sh provided, which does automatically do the above. grc-1.5/CHANGES0000777000000000000000000000000012164041041013075 2debian/changelogustar grc-1.5/COPYING0000777000000000000000000000000012164041041013216 2debian/copyrightustar grc-1.5/CREDITS0000644000000000000000000000056112164041041010033 0ustar Credits where credits are due: These people helped me with ideas, support and other things: Piotr Klaban Jason Tackaberry Eivind Tagseth Edward Betts Joey Hess Miguel Gualdron Daniel Kollar Christian Zuckschwerdt grc-1.5/conf.proftpd0000644000000000000000000000110012164041041011326 0ustar # this configuration file is suitable for displaying proftpd log files # submitted by Pavol Domin # everything in brakets regexp=\[.+?\] colours=cyan count=more ====== # everything in "" regexp=\".+?\" colours=green count=more ====== # ip number regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=bold magenta count=more ====== # STOR regexp=STOR colours=bold red on_white count=more ====== # RETR regexp=RETR colours=black on_white count=more == # first tree fields separated by space regexp=^([\w\.]+?\s)([\w\.]+?\s)([\w\.]+?\s) colours=bold blue, bold yellow, bold magenta