pax_global_header00006660000000000000000000000064125065465510014523gustar00rootroot0000000000000052 comment=900d62a5c182da20abd3f98fd2ea94e33feaad3e grc-1.9/000077500000000000000000000000001250654655100121475ustar00rootroot00000000000000grc-1.9/CHANGES000077700000000000000000000000001250654655100162312debian/changelogustar00rootroot00000000000000grc-1.9/COPYING000077700000000000000000000000001250654655100163522debian/copyrightustar00rootroot00000000000000grc-1.9/CREDITS000066400000000000000000000005611250654655100131710ustar00rootroot00000000000000Credits 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.9/INSTALL000066400000000000000000000016671250654655100132120ustar00rootroot00000000000000=================================================================== 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.9/README000066400000000000000000000217101250654655100130300ustar00rootroot00000000000000=================================================================== 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, replace, count Only regexp is mandatory, but it does not have much sense by itself unless you specify at least a colour, skip, replace 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. replace means the regular expression match will be replaced by the value all the preceeding regular expressions will be evaluated against the original text, but if they match and the replacement changes the length of the text, the colouring will *stay at the same positions*, which is probably not what you want - therefore put the `replace' rule preferrably at the beginning of config file all the following regular expressions will be evaluated against the replaced text, not the original replacement is done by re.sub(), therefore you can use anything python supports - in particular, \1, \2 etc... to include text from the original matching groups, e.g: regexp=(\d\d):(\d\d):(\d\d) replace=\1h\2m\3s will change time format from 09:43:59 into 09h43m59s 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://docs.python.org/dev/howto/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: Following commands will display nice coloured log in virtual console 12: 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 If you want to start using grc automatically with supported commands, add source /etc/grc.bashrc to your .bash_profile (assuming you copied grc.bashrc to /etc) grc-1.9/Regexp.txt000066400000000000000000000260601250654655100141460ustar00rootroot00000000000000 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.9/TODO000066400000000000000000000001121250654655100126310ustar00rootroot00000000000000optimize for speed handle ^C intelligently - almost done (multiline mode) grc-1.9/conf.configure000066400000000000000000000003321250654655100147750ustar00rootroot00000000000000regexp=^checking colours=bold blue ......... regexp=\.\.\. .*$ colours=bold yellow ......... regexp=\.\.\. yes$ colours=bold cyan ......... regexp=\.\.\. no$ colours=bold red ......... regexp=\.\.\.[ ] colours=default grc-1.9/conf.cvs000066400000000000000000000004271250654655100136140ustar00rootroot00000000000000# 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.9/conf.df000066400000000000000000000010321250654655100134030ustar00rootroot00000000000000# FS regexp=^.*?\s colours=green ====== # Size 'K' regexp=\s\d*[.,]?\dKi?\s colours=green ====== # Size 'M' regexp=\s\d*[.,]?\dMi?\s colours=yellow ====== # Size 'G' regexp=\s\d*[.,]?\dGi?\s colours=red ====== # Size 'T' regexp=\s\d*[.,]?\dTi?\s colours=bold red ====== # Mounted on regexp=/[-\w\d./]* colours=bold green ====== # Use 0-60% regexp=[1-6][0-9]?%|0% colours=green ====== # Use 70-90% regexp=[7-9][0-9]% colours=yellow ====== # Use 90-95 regexp=[9][0-5]% colours=red ====== # Use 95-100 regexp=[9][5-9]%|100% colours=bold red grc-1.9/conf.diff000066400000000000000000000006361250654655100137330ustar00rootroot00000000000000# 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.9/conf.dig000066400000000000000000000006171250654655100135650ustar00rootroot00000000000000#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.9/conf.esperanto000066400000000000000000000014161250654655100150200ustar00rootroot00000000000000# 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.9/conf.gcc000066400000000000000000000012371250654655100135550ustar00rootroot00000000000000# 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[^\s]+ 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.9/conf.ifconfig000066400000000000000000000014651250654655100146100ustar00rootroot00000000000000 # ipv4 regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=bold green ======= # ipv6 regexp=\b[0-9a-fA-F]{1,4}(\:\:?[0-9a-fA-F]{1,4})+ colours=bold green ======= # hwaddr regexp=(\d|[a-f]){2}(\:(\d|[a-f]){2}){5} colours=yellow ======= # size regexp=\d+(\.\d+)?\s(T|G|M|K|)i?B colours=yellow ======= # interface regexp=^([a-z0-9]{2,}\d*):?\s colours=bold green ======= #ip disc regexp=(inet6?|netmask|broadcast) colours=cyan ======= #flags regexp=(?<=[,<])[^,]+?(?=[,>]) colours=blue ======= # mtu regexp=(?i)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.9/conf.irclog000066400000000000000000000007151250654655100143000ustar00rootroot00000000000000# 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.9/conf.ldap000066400000000000000000000003531250654655100137370ustar00rootroot00000000000000# 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.9/conf.log000066400000000000000000000017401250654655100136010ustar00rootroot00000000000000# this configuration file is suitable for displaying kernel log files # example of text substitution #regexp=\bda?emon #replace=angel #colours=red #====== # example of text substitution #regexp=(\d\d):(\d\d):(\d\d) #replace=\1h\2m\3s #====== # 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.9/conf.ls000066400000000000000000000017401250654655100134360ustar00rootroot00000000000000# 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.9/conf.mount000066400000000000000000000005001250654655100141530ustar00rootroot00000000000000#/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.9/conf.mount2000066400000000000000000000002261250654655100142420ustar00rootroot00000000000000# Intended for colouring 'mount' output # written by Emanuele Aina regexp=^(.*) on (.*) type (.*) \((.*)\) colours=default,green,yellow,blue,magenta grc-1.9/conf.mtr000066400000000000000000000003531250654655100136210ustar00rootroot00000000000000#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.9/conf.netstat000066400000000000000000000022301250654655100144750ustar00rootroot00000000000000# 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.9/conf.php000066400000000000000000000024341250654655100136100ustar00rootroot00000000000000# this configuration file is suitable for displaying php error log files regexp=\] PHP [^\s]+ error: colours=on_red count=once ====== regexp=\] PHP Notice: colours=on_yellow black count=once ====== regexp=\] PHP Warning: colours=on_cyan count=once ====== regexp=(PHP )?Stack trace: colours=on_green count=once ====== regexp=] PHP [ \d]{2}\d\. colours=on_green count=once ====== # 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 ====== regexp=not found or unable to stat colours=black count=block ====== regexp=File does not exist colours=italic black count=block ====== regexp=^\[ colours=default count=unblock grc-1.9/conf.ping000066400000000000000000000007001250654655100137500ustar00rootroot00000000000000# 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.9/conf.proftpd000066400000000000000000000011001250654655100144640ustar00rootroot00000000000000# 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 grc-1.9/conf.ps000066400000000000000000000014611250654655100134420ustar00rootroot00000000000000# /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.9/conf.traceroute000066400000000000000000000011161250654655100151720ustar00rootroot00000000000000# 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.9/conf.wdiff000066400000000000000000000002041250654655100141110ustar00rootroot00000000000000# new words regexp=\{\+.+\+\} colours=bold green count=more ======= # deleted words regexp=\[\-.+\-\] colours=bold green count=more grc-1.9/contrib/000077500000000000000000000000001250654655100136075ustar00rootroot00000000000000grc-1.9/contrib/conf.efingerd000066400000000000000000000007711250654655100162460ustar00rootroot00000000000000# 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.9/contrib/nmh-in-color/000077500000000000000000000000001250654655100161115ustar00rootroot00000000000000grc-1.9/contrib/nmh-in-color/README000066400000000000000000000061461250654655100170000ustar00rootroot00000000000000-------------- 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.9/contrib/nmh-in-color/configs/000077500000000000000000000000001250654655100175415ustar00rootroot00000000000000grc-1.9/contrib/nmh-in-color/configs/bashrc-entries000066400000000000000000000024571250654655100224050ustar00rootroot00000000000000#---------------------------------------------------------------------- # 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.9/contrib/nmh-in-color/configs/conf.flists000066400000000000000000000007571250654655100217250ustar00rootroot00000000000000#--------------------------------------------------------------------------- # $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.9/contrib/nmh-in-color/configs/conf.inc000066400000000000000000000007311250654655100211620ustar00rootroot00000000000000#--------------------------------------------------------------------------- # $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.9/contrib/nmh-in-color/configs/conf.mail000066400000000000000000000077311250654655100213420ustar00rootroot00000000000000#--------------------------------------------------------------------------- # $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.9/contrib/nmh-in-color/configs/conf.scan000066400000000000000000000014071250654655100213360ustar00rootroot00000000000000#--------------------------------------------------------------------------- # $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.9/contrib/nmh-in-color/configs/grc.conf-entries000066400000000000000000000004171250654655100226340ustar00rootroot00000000000000# # 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.9/contrib/nmh-in-color/configs/mh_profile-entries000066400000000000000000000006111250654655100232550ustar00rootroot00000000000000#: #: 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.9/contrib/nmh-in-color/configs/mhl.body000066400000000000000000000001141250654655100211740ustar00rootroot00000000000000body:nocomponent,width=79,overflowtext="*** ",overflowoffset=5,noleftadjust grc-1.9/contrib/nmh-in-color/configs/mhl.format000066400000000000000000000012401250654655100215300ustar00rootroot00000000000000; 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.9/contrib/nmh-in-color/configs/mhl.headers000066400000000000000000000010551250654655100216570ustar00rootroot00000000000000; 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.9/contrib/nmh-in-color/configs/rxvt-resources000066400000000000000000000015411250654655100225000ustar00rootroot00000000000000!-------------------------------------------------------------- ! 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.9/contrib/nmh-in-color/scripts/000077500000000000000000000000001250654655100176005ustar00rootroot00000000000000grc-1.9/contrib/nmh-in-color/scripts/viewmail000077500000000000000000000020101250654655100213340ustar00rootroot00000000000000#!/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.9/contrib/nmh-in-color/scripts/vimail000077500000000000000000000010571250654655100210120ustar00rootroot00000000000000#!/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.9/contrib/wrap-ccache000077500000000000000000000007771250654655100157250ustar00rootroot00000000000000#!/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.9/debian/000077500000000000000000000000001250654655100133715ustar00rootroot00000000000000grc-1.9/debian/README.Debian000066400000000000000000000001611250654655100154300ustar00rootroot00000000000000grc ---------------------- packaged as native package -- Radovan Garabík grc-1.9/debian/changelog000066400000000000000000000177761250654655100152650ustar00rootroot00000000000000grc (1.9-1) unstable; urgency=low * add `colors' as a synonym of `colours' (and the singulars, too) -- Radovan Garabík Tue, 31 Mar 2015 17:44:11 +0200 grc (1.8-1) unstable; urgency=low * added support for Ki, Gi, Ti for df (thanks to Juraj Bednár) * added example aliases for bash (thanks to Juraj Bednár) * fix infinite loop if regexp matches but does not consume anything -- Radovan Garabík Mon, 16 Mar 2015 14:38:42 +0100 grc (1.7-1) unstable; urgency=low * added `replace' keyword to replace arbitrary text (idea by Ben Hoskins) * added config.php to display php error log (thanks to Ben Hoskins) * added aixterm bright colour codes (thanks to April Arcus) * minor cleanups * switch to non-native Debian package -- Radovan Garabík Fri, 27 Feb 2015 11:09:48 +0100 grc (1.6) unstable; urgency=low * add several configuration files (thanks to Mrs. Smith) -- Radovan Garabík Wed, 30 Oct 2013 15:15:20 +0100 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.9/debian/compat000066400000000000000000000000021250654655100145670ustar00rootroot000000000000009 grc-1.9/debian/control000066400000000000000000000006171250654655100150000ustar00rootroot00000000000000Source: grc Section: text Priority: optional Maintainer: Radovan Garabík Standards-Version: 3.9.6 Build-Depends: debhelper (>=9) Package: grc Architecture: all Depends: python, ${misc:Depends} Description: generic colouriser for everything generic colouriser, can be used to colourise logfiles, output of commands, arbitrary text.... configured via regexp's. grc-1.9/debian/copyright000066400000000000000000000021561250654655100153300ustar00rootroot00000000000000This is grc, written and maintained by Radovan Garabík on Thu, 14 Oct 1999 19:24:25 +0200. Upstream Author: Radovan Garabík Copyright: Copyright © 2014 Radovan Garabík The original source can be found at: http://kassiopeia.juls.savba.sk/~garabik/software/grc.html It is released under GPL v2 or any later version, under Debian systems see /usr/share/common-licenses/GPL-2, 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.9/debian/dirs000066400000000000000000000000261250654655100142530ustar00rootroot00000000000000usr/bin usr/share/grc grc-1.9/debian/docs000066400000000000000000000000501250654655100142370ustar00rootroot00000000000000TODO README Regexp.txt CREDITS contrib/ grc-1.9/debian/rules000077500000000000000000000023141250654655100144510ustar00rootroot00000000000000#!/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 clean: dh_testdir dh_testroot rm -f build-stamp dh_clean install: dh_testdir dh_testroot dh_prep dh_installdirs # Add here commands to install the package into debian/tmp. ./install.sh `pwd`/debian/grc build: build-arch build-indep build-arch: build-stamp build-indep: build-stamp build-stamp: # nothing to do # Build architecture-dependent files here. binary-arch: install # nothing to do # 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.9/debian/source/000077500000000000000000000000001250654655100146715ustar00rootroot00000000000000grc-1.9/debian/source/format000066400000000000000000000000141250654655100160770ustar00rootroot000000000000003.0 (quilt) grc-1.9/grc000077500000000000000000000074771250654655100126670ustar00rootroot00000000000000#! /usr/bin/python import os, re, string, sys, getopt, signal def version(): print ("Generic Colouriser 1.9") sys.exit() def help(): print("""Generic Colouriser 1.9 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.9/grc.1000066400000000000000000000027061250654655100130110ustar00rootroot00000000000000.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.9/grc.bashrc000066400000000000000000000012751250654655100141130ustar00rootroot00000000000000GRC=`which grc` if [ "$TERM" != dumb ] && [ -n "$GRC" ] then alias colourify="$GRC -es --colour=auto" alias configure='colourify ./configure' alias diff='colourify diff' alias make='colourify make' alias gcc='colourify gcc' alias g++='colourify g++' alias as='colourify as' alias gas='colourify gas' alias ld='colourify ld' alias netstat='colourify netstat' alias ping='colourify ping' alias traceroute='colourify /usr/sbin/traceroute' alias head='colourify head' alias tail='colourify tail' alias dig='colourify dig' alias mount='colourify mount' alias ps='colourify ps' alias mtr='colourify mtr' alias df='colourify df' fi grc-1.9/grc.conf000066400000000000000000000017421250654655100135750ustar00rootroot00000000000000# 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 # mount (^|[/\w\.]+/)mount\s? conf.mount # df (^|[/\w\.]+/)df\s? conf.df grc-1.9/grc.spec000066400000000000000000000026771250654655100136120ustar00rootroot00000000000000# 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.9/grc.spec.old000066400000000000000000000024511250654655100143550ustar00rootroot00000000000000# 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.9/grcat000077500000000000000000000212211250654655100131730ustar00rootroot00000000000000#! /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", # aixterm bright color codes # prefixed with standard ANSI codes for graceful failure 'bright_black' : "\033[30;90m", 'bright_red' : "\033[31;91m", 'bright_green' : "\033[32;92m", 'bright_yellow' : "\033[33;93m", 'bright_blue' : "\033[34;94m", 'bright_magenta' : "\033[35;95m", 'bright_cyan' : "\033[36;96m", 'bright_white' : "\033[37;97m", 'on_bright_black' : "\033[40;100m", 'on_bright_red' : "\033[41;101m", 'on_bright_green' : "\033[42;102m", 'on_bright_yellow' : "\033[43;103m", 'on_bright_blue' : "\033[44;104m", 'on_bright_magenta' : "\033[45;105m", 'on_bright_cyan' : "\033[46;106m", 'on_bright_white' : "\033[47;107m", } # 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/"] if len(sys.argv) != 2: sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n") sys.exit(1) 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 keyword in ('colors', 'colour', 'color'): keyword = 'colours' if not keyword in ["regexp", "colours", "count", "command", "skip", "replace"]: 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 if line[-1] in '\r\n': 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 'replace' in pattern: line = re.sub(m.re, pattern['replace'], line) #m = pattern['regexp'](line, pos) #if not m: # break 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" newpos = m.end(0) # special case, if the regexp matched but did not consume anything, # advance the position by 1 to escape endless loop if newpos == pos: pos += 1 else: pos = newpos 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.9/grcat.1000066400000000000000000000046561250654655100133440ustar00rootroot00000000000000.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 replace means the regular expression match will be replaced by the value, all the preceeding regular expressions will be evaluated against the original text, all the following regular expressions will be evaluated against the replaced text .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.9/install.sh000077500000000000000000000004411250654655100141530ustar00rootroot00000000000000#!/bin/sh set -e 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.9/mrsmith/000077500000000000000000000000001250654655100136325ustar00rootroot00000000000000grc-1.9/mrsmith/conf.dig000066400000000000000000000010411250654655100152400ustar00rootroot00000000000000#comments regexp=;\s\w*\s*\w*.* colours=yellow ======= #comments 2 regexp=;;\s\w*\s*\w*.* colours=white ======= #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=\s(A|AAAA|NS|PTR|MX|CNAME|TXT|COA)(\s|$) colours=cyan ======= #in regexp=\s(IN|CH)\s colours=yellow ======= #domain regexp=@?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}\.? colours=magenta ======= #ip address regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=green #======= grc-1.9/mrsmith/conf.ifconfig000066400000000000000000000016241250654655100162700ustar00rootroot00000000000000# ip regexp=\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b colours=bold green ======= # ipv6 regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+ colours=bold green ======= # hwaddr regexp=([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F]) colours=yellow ======= # size regexp=\d+(\.\d+)?\s((T|G|M|K)i)?B colours=yellow ======= # interface regexp=(([0-9a-z]{3,8}\d)|lo): colours=bold green ======= #ip disc regexp=(inet6?|netmask|broadcast) colours=cyan ======= #flags regexp=(?<=[,<])[^,]*(?=[,>]) colours=blue ======= # mtu regexp=mtu\s\d+ colours=green ======= # unspec regexp=(unspec|UNSPEC) colours=bold red ======= #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.9/mrsmith/conf.mtr000066400000000000000000000007311250654655100153040ustar00rootroot00000000000000#ip address regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} colours=green ======= # % 0.0 - 10.9 % loss regexp=[^\d][0-9]{1}.\d% colours=green ======= # % 11.0 - 30.9 % loss regexp=[123]{1}[0-9]{1}.\d% colours=yellow ======= # % 30.0 - 80.9% loss regexp=[3-8]{1}[0-9]{1}.\d% colours=bold yellow ======= # % 80.0 - 95.9% loss regexp=[8-9]{1}[0-9]{1}.\d% colours=red ======= # unknow host regexp=\?\?\? colours=red ======= # Packets/Pings regexp=(Packets|Pings) colours=bold green grc-1.9/mrsmith/conf.netstat000066400000000000000000000022621250654655100161650ustar00rootroot00000000000000# hostname:service regexp=(\S*):(\d{1,5}|\S*)\s colours=yellow, bold green, bold yellow ======= # ipx hostname regexp=^IPX.*[\dABCDEF]+:[\dABCDEF]+ colours=green ======= # protocols TCP regexp=tcp6? colours=bold blue ======= # protocols UDP regexp=udp6? colours=bold cyan ======= # protocols other regexp=(^unix|^IPX|STREAM|DGRAM|SEQPACKET) colours=bold green ======= # 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 ======= # path regexp=(\@)[\dabcdef]+ colours=green, bold green ======= # timewait regexp=timewait\s\((.*\)) colours=green, red ======= # timewait off regexp=off.* colours=bold red ======= # process name regexp=\s(\d*)/(\S*)\s colours=yellow,bold cyan, bold green grc-1.9/mrsmith/conf.ps000066400000000000000000000021301250654655100151170ustar00rootroot00000000000000# CAPS LINE regexp=^[A-Z\s%]*([A-Z]{3})[A-Z\s%]*$ colours=underline ======= # /full/path regexp=(\s|^)/[-\w\d.]+/[-\w\d./]+ colours=white ======= # 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 user 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 ======= # time regexp=(\d*:)?\d*:\d{2} colours=bold white ======= # time 00:00:00 regexp=00:00:00 colours=bold black ====== # time 0:00 regexp=\s0:00\s colours=bold black ====== # ? regexp=\s\?\s colours=red ======= # Process state regexp=\s([DRSTEXZ])([NLsl+<]*)\s colours=cyan, bold blue