diff --git a/CHANGES b/CHANGES new file mode 120000 index 0000000..d526672 --- /dev/null +++ b/CHANGES @@ -0,0 +1 @@ +debian/changelog \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..9060ce8 --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +debian/copyright \ No newline at end of file diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..5553962 --- /dev/null +++ b/CREDITS @@ -0,0 +1,11 @@ +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 diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..a4667c3 --- /dev/null +++ b/INSTALL @@ -0,0 +1,32 @@ +=================================================================== + 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. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d6a9326..0000000 --- a/LICENSE +++ /dev/null @@ -1,340 +0,0 @@ -GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {description} - Copyright (C) {year} {fullname} - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - {signature of Ty Coon}, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. - diff --git a/README b/README new file mode 100644 index 0000000..87d48e3 --- /dev/null +++ b/README @@ -0,0 +1,227 @@ +=================================================================== + 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 + diff --git a/README.md b/README.md deleted file mode 100644 index 95d4b96..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# grc -generic colouriser diff --git a/Regexp.txt b/Regexp.txt new file mode 100644 index 0000000..2b3dca3 --- /dev/null +++ b/Regexp.txt @@ -0,0 +1,187 @@ + +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. diff --git a/TODO b/TODO new file mode 100644 index 0000000..19e256d --- /dev/null +++ b/TODO @@ -0,0 +1,3 @@ +optimize for speed +handle ^C intelligently - almost done +(multiline mode) diff --git a/build-stamp b/build-stamp new file mode 100644 index 0000000..e69de29 diff --git a/conf.configure b/conf.configure new file mode 100644 index 0000000..ac88ec7 --- /dev/null +++ b/conf.configure @@ -0,0 +1,14 @@ +regexp=^checking +colours=bold blue +......... +regexp=\.\.\. .*$ +colours=bold yellow +......... +regexp=\.\.\. yes$ +colours=bold cyan +......... +regexp=\.\.\. no$ +colours=bold red +......... +regexp=\.\.\.[ ] +colours=default diff --git a/conf.cvs b/conf.cvs new file mode 100644 index 0000000..53e2fab --- /dev/null +++ b/conf.cvs @@ -0,0 +1,24 @@ +# 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 diff --git a/conf.df b/conf.df new file mode 100644 index 0000000..c18ba8e --- /dev/null +++ b/conf.df @@ -0,0 +1,39 @@ +# FS +regexp=^.*?\s +colours=green +====== +# Size 'K' +regexp=\s\d*[.,]?\dK\s +colours=green +====== +# Size 'M' +regexp=\s\d*[.,]?\dM\s +colours=yellow +====== +# Size 'G' +regexp=\s\d*[.,]?\dG\s +colours=red +====== +# Size 'T' +regexp=\s\d*[.,]?\dT\s +colours=bold red +====== +# Mounted on +regexp=/\w* +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 diff --git a/conf.diff b/conf.diff new file mode 100644 index 0000000..f7a51e3 --- /dev/null +++ b/conf.diff @@ -0,0 +1,24 @@ +# 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 diff --git a/conf.dig b/conf.dig new file mode 100644 index 0000000..5c3aaae --- /dev/null +++ b/conf.dig @@ -0,0 +1,29 @@ +#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 +#======= + diff --git a/conf.esperanto b/conf.esperanto new file mode 100644 index 0000000..ad55a00 --- /dev/null +++ b/conf.esperanto @@ -0,0 +1,54 @@ +# 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 diff --git a/conf.gcc b/conf.gcc new file mode 100644 index 0000000..84674e0 --- /dev/null +++ b/conf.gcc @@ -0,0 +1,48 @@ +# +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 diff --git a/conf.ifconfig b/conf.ifconfig new file mode 100644 index 0000000..92059e4 --- /dev/null +++ b/conf.ifconfig @@ -0,0 +1,51 @@ + +# 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-z]{3,}\d*)|lo)\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 diff --git a/conf.irclog b/conf.irclog new file mode 100644 index 0000000..b76da48 --- /dev/null +++ b/conf.irclog @@ -0,0 +1,32 @@ +# 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 diff --git a/conf.ldap b/conf.ldap new file mode 100644 index 0000000..6b872c8 --- /dev/null +++ b/conf.ldap @@ -0,0 +1,15 @@ +# 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 diff --git a/conf.log b/conf.log new file mode 100644 index 0000000..e1422ba --- /dev/null +++ b/conf.log @@ -0,0 +1,41 @@ +# 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 diff --git a/conf.ls b/conf.ls new file mode 100644 index 0000000..3c76597 --- /dev/null +++ b/conf.ls @@ -0,0 +1,31 @@ +# 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 diff --git a/conf.mount b/conf.mount new file mode 100644 index 0000000..ed316c2 --- /dev/null +++ b/conf.mount @@ -0,0 +1,19 @@ +#/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 diff --git a/conf.mount2 b/conf.mount2 new file mode 100644 index 0000000..b85ca87 --- /dev/null +++ b/conf.mount2 @@ -0,0 +1,5 @@ +# Intended for colouring 'mount' output +# written by Emanuele Aina + +regexp=^(.*) on (.*) type (.*) \((.*)\) +colours=default,green,yellow,blue,magenta diff --git a/conf.mtr b/conf.mtr new file mode 100644 index 0000000..02e0c5c --- /dev/null +++ b/conf.mtr @@ -0,0 +1,15 @@ +#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 diff --git a/conf.netstat b/conf.netstat new file mode 100644 index 0000000..2dd96e3 --- /dev/null +++ b/conf.netstat @@ -0,0 +1,76 @@ +# 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 diff --git a/conf.ping b/conf.ping new file mode 100644 index 0000000..b152da9 --- /dev/null +++ b/conf.ping @@ -0,0 +1,31 @@ +# 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 diff --git a/conf.proftpd b/conf.proftpd new file mode 100644 index 0000000..5c33e60 --- /dev/null +++ b/conf.proftpd @@ -0,0 +1,31 @@ +# 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 diff --git a/conf.ps b/conf.ps new file mode 100644 index 0000000..c410d5d --- /dev/null +++ b/conf.ps @@ -0,0 +1,47 @@ +# /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 diff --git a/conf.traceroute b/conf.traceroute new file mode 100644 index 0000000..b6501a2 --- /dev/null +++ b/conf.traceroute @@ -0,0 +1,42 @@ +# 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 diff --git a/conf.wdiff b/conf.wdiff new file mode 100644 index 0000000..39e23de --- /dev/null +++ b/conf.wdiff @@ -0,0 +1,9 @@ +# new words +regexp=\{\+.+\+\} +colours=bold green +count=more +======= +# deleted words +regexp=\[\-.+\-\] +colours=bold green +count=more diff --git a/contrib/conf.efingerd b/contrib/conf.efingerd new file mode 100644 index 0000000..48056b8 --- /dev/null +++ b/contrib/conf.efingerd @@ -0,0 +1,26 @@ +# 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 diff --git a/contrib/nmh-in-color/README b/contrib/nmh-in-color/README new file mode 100644 index 0000000..f95ab39 --- /dev/null +++ b/contrib/nmh-in-color/README @@ -0,0 +1,78 @@ +-------------- +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 $ +#--------------------------------------------------------------------------- diff --git a/contrib/nmh-in-color/configs/bashrc-entries b/contrib/nmh-in-color/configs/bashrc-entries new file mode 100644 index 0000000..ebb773f --- /dev/null +++ b/contrib/nmh-in-color/configs/bashrc-entries @@ -0,0 +1,27 @@ +#---------------------------------------------------------------------- +# 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" diff --git a/contrib/nmh-in-color/configs/conf.flists b/contrib/nmh-in-color/configs/conf.flists new file mode 100644 index 0000000..741aa6e --- /dev/null +++ b/contrib/nmh-in-color/configs/conf.flists @@ -0,0 +1,14 @@ +#--------------------------------------------------------------------------- +# $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 diff --git a/contrib/nmh-in-color/configs/conf.inc b/contrib/nmh-in-color/configs/conf.inc new file mode 100644 index 0000000..5751ac9 --- /dev/null +++ b/contrib/nmh-in-color/configs/conf.inc @@ -0,0 +1,14 @@ +#--------------------------------------------------------------------------- +# $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 diff --git a/contrib/nmh-in-color/configs/conf.mail b/contrib/nmh-in-color/configs/conf.mail new file mode 100644 index 0000000..53b45cc --- /dev/null +++ b/contrib/nmh-in-color/configs/conf.mail @@ -0,0 +1,132 @@ +#--------------------------------------------------------------------------- +# $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 diff --git a/contrib/nmh-in-color/configs/conf.scan b/contrib/nmh-in-color/configs/conf.scan new file mode 100644 index 0000000..5b12dd3 --- /dev/null +++ b/contrib/nmh-in-color/configs/conf.scan @@ -0,0 +1,31 @@ +#--------------------------------------------------------------------------- +# $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 diff --git a/contrib/nmh-in-color/configs/grc.conf-entries b/contrib/nmh-in-color/configs/grc.conf-entries new file mode 100644 index 0000000..b5efcdd --- /dev/null +++ b/contrib/nmh-in-color/configs/grc.conf-entries @@ -0,0 +1,15 @@ +# +# 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 diff --git a/contrib/nmh-in-color/configs/mh_profile-entries b/contrib/nmh-in-color/configs/mh_profile-entries new file mode 100644 index 0000000..47462e1 --- /dev/null +++ b/contrib/nmh-in-color/configs/mh_profile-entries @@ -0,0 +1,13 @@ +#: +#: 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 diff --git a/contrib/nmh-in-color/configs/mhl.body b/contrib/nmh-in-color/configs/mhl.body new file mode 100644 index 0000000..d11c90d --- /dev/null +++ b/contrib/nmh-in-color/configs/mhl.body @@ -0,0 +1 @@ +body:nocomponent,width=79,overflowtext="*** ",overflowoffset=5,noleftadjust diff --git a/contrib/nmh-in-color/configs/mhl.format b/contrib/nmh-in-color/configs/mhl.format new file mode 100644 index 0000000..cc2c566 --- /dev/null +++ b/contrib/nmh-in-color/configs/mhl.format @@ -0,0 +1,22 @@ +; 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 diff --git a/contrib/nmh-in-color/configs/mhl.headers b/contrib/nmh-in-color/configs/mhl.headers new file mode 100644 index 0000000..183c05c --- /dev/null +++ b/contrib/nmh-in-color/configs/mhl.headers @@ -0,0 +1,20 @@ +; 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 +: diff --git a/contrib/nmh-in-color/configs/rxvt-resources b/contrib/nmh-in-color/configs/rxvt-resources new file mode 100644 index 0000000..cf1fbab --- /dev/null +++ b/contrib/nmh-in-color/configs/rxvt-resources @@ -0,0 +1,30 @@ +!-------------------------------------------------------------- +! 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 diff --git a/contrib/nmh-in-color/scripts/viewmail b/contrib/nmh-in-color/scripts/viewmail new file mode 100755 index 0000000..e326167 --- /dev/null +++ b/contrib/nmh-in-color/scripts/viewmail @@ -0,0 +1,37 @@ +#!/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 diff --git a/contrib/nmh-in-color/scripts/vimail b/contrib/nmh-in-color/scripts/vimail new file mode 100755 index 0000000..0bede40 --- /dev/null +++ b/contrib/nmh-in-color/scripts/vimail @@ -0,0 +1,15 @@ +#!/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 diff --git a/contrib/wrap-ccache b/contrib/wrap-ccache new file mode 100755 index 0000000..2534870 --- /dev/null +++ b/contrib/wrap-ccache @@ -0,0 +1,28 @@ +#!/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 "$@" diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..a8d2e27 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,6 @@ +grc +---------------------- + +packaged as native package + + -- Radovan Garabík diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..19995b1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,213 @@ +grc (1.6) unstable; urgency=low + + * add several configuration files (thanks to Mrs. Smith) + + -- Radovan Garabik 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: diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..ef555b9 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +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. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c68f326 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,19 @@ +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 diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..7e0e322 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/grc diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..3a066b4 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +TODO README Regexp.txt CREDITS contrib/ diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..4e5f354 --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +grc_1.5_all.deb text optional diff --git a/debian/grc.debhelper.log b/debian/grc.debhelper.log new file mode 100644 index 0000000..13cc91d --- /dev/null +++ b/debian/grc.debhelper.log @@ -0,0 +1,18 @@ +dh_installdirs +dh_installdocs +dh_installexamples +dh_installmenu +dh_installcron +dh_installman +dh_installinfo +dh_installchangelogs +dh_link +dh_strip +dh_compress +dh_fixperms +dh_installdeb +dh_shlibdeps +dh_gencontrol +dh_md5sums +dh_builddeb +dh_builddeb diff --git a/debian/grc.substvars b/debian/grc.substvars new file mode 100644 index 0000000..abd3ebe --- /dev/null +++ b/debian/grc.substvars @@ -0,0 +1 @@ +misc:Depends= diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..522ee13 --- /dev/null +++ b/debian/rules @@ -0,0 +1,74 @@ +#!/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 diff --git a/grc b/grc new file mode 100755 index 0000000..1b91397 --- /dev/null +++ b/grc @@ -0,0 +1,170 @@ +#! /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)) + + diff --git a/grc.1 b/grc.1 new file mode 100644 index 0000000..30d0296 --- /dev/null +++ b/grc.1 @@ -0,0 +1,76 @@ +.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 diff --git a/grc.conf b/grc.conf new file mode 100644 index 0000000..cb3c245 --- /dev/null +++ b/grc.conf @@ -0,0 +1,76 @@ +# 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 + diff --git a/grc.spec b/grc.spec new file mode 100644 index 0000000..6efbde7 --- /dev/null +++ b/grc.spec @@ -0,0 +1,57 @@ +# 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 diff --git a/grc.spec.old b/grc.spec.old new file mode 100644 index 0000000..214af28 --- /dev/null +++ b/grc.spec.old @@ -0,0 +1,52 @@ +# 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/* diff --git a/grcat b/grcat new file mode 100755 index 0000000..6a26d20 --- /dev/null +++ b/grcat @@ -0,0 +1,219 @@ +#! /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 + diff --git a/grcat.1 b/grcat.1 new file mode 100644 index 0000000..6b05d79 --- /dev/null +++ b/grcat.1 @@ -0,0 +1,89 @@ +.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 diff --git a/install-stamp b/install-stamp new file mode 100644 index 0000000..e69de29 diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..e44e71e --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/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 diff --git a/mrsmith/conf.dig b/mrsmith/conf.dig new file mode 100644 index 0000000..de6a396 --- /dev/null +++ b/mrsmith/conf.dig @@ -0,0 +1,33 @@ +#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 +#======= + diff --git a/mrsmith/conf.ifconfig b/mrsmith/conf.ifconfig new file mode 100644 index 0000000..3b613ae --- /dev/null +++ b/mrsmith/conf.ifconfig @@ -0,0 +1,54 @@ +# 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 diff --git a/mrsmith/conf.mtr b/mrsmith/conf.mtr new file mode 100644 index 0000000..6a673f5 --- /dev/null +++ b/mrsmith/conf.mtr @@ -0,0 +1,27 @@ +#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 diff --git a/mrsmith/conf.netstat b/mrsmith/conf.netstat new file mode 100644 index 0000000..4a5d699 --- /dev/null +++ b/mrsmith/conf.netstat @@ -0,0 +1,80 @@ +# 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 diff --git a/mrsmith/conf.ps b/mrsmith/conf.ps new file mode 100644 index 0000000..ab40f93 --- /dev/null +++ b/mrsmith/conf.ps @@ -0,0 +1,67 @@ +# 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