{"id":16867042,"url":"https://github.com/pengwynn/grc","last_synced_at":"2025-03-17T05:32:45.492Z","repository":{"id":3044824,"uuid":"4065948","full_name":"pengwynn/grc","owner":"pengwynn","description":"Mirror of Radovan Garabík's - Generic Colourizer for terminal apps","archived":false,"fork":false,"pushed_at":"2015-09-02T09:48:54.000Z","size":152,"stargazers_count":138,"open_issues_count":4,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T18:36:57.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://korpus.juls.savba.sk/~garabik/software/grc.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pengwynn.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-18T16:47:46.000Z","updated_at":"2024-10-29T15:55:31.000Z","dependencies_parsed_at":"2022-08-18T00:40:38.029Z","dependency_job_id":null,"html_url":"https://github.com/pengwynn/grc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengwynn%2Fgrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengwynn%2Fgrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengwynn%2Fgrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pengwynn%2Fgrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pengwynn","download_url":"https://codeload.github.com/pengwynn/grc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846978,"owners_count":20357297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T14:52:32.830Z","updated_at":"2025-03-17T05:32:44.970Z","avatar_url":"https://github.com/pengwynn.png","language":"JavaScript","funding_links":[],"categories":["\u003ca name=\"text-processing\"\u003e\u003c/a\u003eText processing"],"sub_categories":[],"readme":"===================================================================\n                  Generic Colouriser\n\nRadovan Garabík  http://kassiopeia.juls.savba.sk/~garabik/software/grc.html\ngarabik @ kassiopeia.juls.savba.sk\n\n===================================================================\n\nBeing overflooded with different logfile colo(u)?ri(s|z)ers, colortails,\ngccolors, colormakes and similar programs for making  text files or outputs\nof different programs more readable by inserting ansi colour control codes\ninto them, I decided to write  my very own colouriser, eventually providing\nthe functions of all those others.\n\nTwo programs are provided: grc and grcat.  The main is grcat, which acts as\na filter, i.e. taking standard input, colourising it and writing to\nstandard output.\n\ngrcat takes as a parameter the name of configuration file.\n\nDirectories  ~/.grc/, /usr/local/share/grc/, /usr/share/grc/ are searched\nfor the file (in this order). If the file is not found, it is assumed to be\nan absolute path of a configuration file located elsewhere.\n\nConfiguration file consists of entries, one per regexp, entries are \n    separated with lines with first character non-alphanumeric (except #).\n    Lines beginning with # or empty lines are ignored.\n\n    Each entry consists of several lines.\n    Each line has form:\n        keyword=value\n        where keyword is one of: regexp, colours, command, skip, count\n        Only regexp is mandatory, but it does not have much sense by itself\n        unless you specify at least a colour, skip or command keyword as well.\n\n        regexp is the regular expression to match\n\n        colours is the list of colours, separated by commas (you can specify only \n        one colour), each colour per one regexp group specified in regexp.\n        if you use special colour name \"previous\", colour of the previous line\n        of text will be used (actually, if both the first and last character of \n        the previous line are of different colour than the default one,\n        colour of the first one will be used).\n        Another special colour name \"unchanged\" will leave the colour \n        unchanged, useful if you need some context for matching \n        regular expression and you want to leave the colour of context\n        unchanged.\n        Yet another special name is an arbitrary string enclosed in \n        straight quotes. This string will be inserted directly into\n        the output in front of the matching expression. The string will\n        be eval'ed, so you can use usual python escape sequences.\n        This is useful on a 256-colour enabled xterm, where e.g.\n         colours=\"\\033[38;5;22m\" will give you a dark green (inspired\n        by Rutger Ovidius). Caveat: the string cannot contain a comma. This\n        is due to my laziness :-)\n\n\n        command is command to be executed when regexp matches. Its output will\n        be mixed with normal stdout, use redirectors ( \u003e/dev/null) if you want\n        to suppress it.\n        \n        skip can be skip=yes, if that case the matched line is skipped\n        (discarded from the output), or skip=no, when it is not skipped.\n        Default (if you do not have skip keyword) is of course not skipped.\n\n        count is one of words: once, more, stop, previous, block or unblock\n\n            once means that if the regexp is matched, its first occurrence is coloured\n            and the program will continue with other regexp's.\n\n            more means that if there are multiple matches of the regexp in one line,\n            all of them will be coloured.\n\n            stop means that the regexp will be coloured and program will move to the\n            next line (i.e. ignoring other regexp's) \n            \n            previous means the count will be the same as for the previous line\n            \n            block marks a start of a multiline block of text, coloured with\n            the same colour\n            \n            unblock, obviously, marks the end of such a block\n\n\n\n        example:\n\n        # this is probably a pathname\n        regexp=/[\\w/\\.]+\n        colour=green\n        count=more\n\n        this will match /usr/bin, /usr/local/bin/, /etc/init.d/syslogd and similar\n        strings and paint it with green.\n\n        Another example:\n\n        regexp=^-{1,2}\\s{0,1}$\n        colours=red\n        count=block\n        -\n        regexp=^\\s{0,5}$\n        colours=default\n        count=unblock\n    \n        this will turn all correctly formatted mail signatures red.\n\n    Regular expressions are evaluated from top to bottom, this allows nested\n    and overlapped expressions. (e.g. you colour everything inside parentheses\n    with one colour, and if a following expression matches the text inside \n    parentheses, it will be also coloured)\n\nTypical usage:\n\ngrcat conf.log \u003c /var/log/syslog\n/usr/sbin/traceroute www.linux.org | grcat conf.traceroute\ngrcat conf.esperanto \u003c Fundamento.txt  | less -r\n\nTo facilitate the use, command grc acts as frontend for grcat, automatically \nchoosing the configuration files, so you can write:\n\ngrc netstat\ngrc ping hostname\ngrc tail /var/log/syslog\n\netc...\n\n    grc will execute command command with optional parameters piping its stdout\n    into grcat.\n\n    Configuration file for grcat is determined by /etc/grc.conf or \n    ~/.grc/grc.conf file.\n\n    Format of /etc/grc.conf or ~/.grc/grc.conf: each entry consists of 2 lines,\n        between entries there can be any number of empty lines or lines beginning\n        with # (comments)\n\n        First line is regular expression, second line the name of configuration\n        file for grcat.\n\n        Configuration file after the first regular expression matching the rest of\n        line after grc will be passed to grcat as its configuration file\n\n        For example, if you have \n\n        # log file\n        \\b\\w+\\b.*log\\b\n        conf.log\n\n        # traceroute command\n        (^|[/\\w\\.]+/)traceroute\\s\n        conf.traceroute\n\n        in your /etc/grc.conf, then typing grc cat /var/log/syslog will use \n        conf.log to colourise the output,\n        grc /usr/sbin/traceroute www.linux.org will use conf.traceroute\n    \nMiscellaneous remarks:\n\n    You should get yourself familiar with regular expressions. Good reading is \n    at http://docs.python.org/dev/howto/regex.html\n\n    The program is not yet optimized for speed. There are places that can \n    give a big boost if optimized.\n\n    Regular expressions are handled by python, it means that they may be\n    slightly different from those you know from perl or grep. It's not my \n    fault in that case.\n\n    Colours are one of: \n        none, default, bold, underline, blink, reverse, concealed, \n        black, green, yellow, blue, magenta, cyan, white,\n        on_black, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white\n        beep\n    on_red means that the background (instead of foreground) is painted \n    with red etc...\n\n    Additional colours can be: dark, italic, rapidblink, strikethrough.\n    These are supported only on some terminals, so if you want to write\n    portable configuration files, avoid uing them (idea by James Rowe).\n\n    there can be more attributes per line (separated by space), e.g.\n\n    # this is probably a pathname\n    regexp=/[\\w/\\.]+\n    colours=bold blink green\n    count=more\n\n    will display pathnames in bold blinking green\n\n\n\nHint taken from logcoloriser README:\n\nTo have your syslog show on your tty12 in colour, do:\n    mkfifo /dev/grc\n    replace (or copy and edit) the /etc/syslog.conf line\n    *.info;mail.*;authpriv.*;kern.*;local1.* |/dev/xconsole\n    with :\n    *.info;mail.*;authpriv.*;kern.*;local1.* |/dev/grc\n    and add to your syslog startup script :\n    grcat conf.log \u003c /dev/grc \u003e/dev/tty12 \u0026\n\nWell, simpler approach seems to be to use something like this\nin your system startup script, if you have GNU tail:\n    tail --follow=name /var/log/syslog | grcat conf.log \u003e/dev/tty12 \nor, if you have recent BSD tail:\n\n    tail -F /var/log/syslog | grcat conf.log \u003e/dev/tty12\n    ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengwynn%2Fgrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpengwynn%2Fgrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpengwynn%2Fgrc/lists"}