diff options
-rw-r--r-- | man1/hl.1 | 19 | ||||
-rw-r--r-- | src/.hl.cfg | 134 | ||||
-rw-r--r-- | src/cr_main.c | 44 | ||||
-rwxr-xr-x | src/hl | bin | 36120 -> 36120 bytes |
4 files changed, 165 insertions, 32 deletions
@@ -1,10 +1,10 @@ -.\" @(#) [MB] cr_hl.1 Version 1.5 du 15/08/08 - +.\" @(#) [MB] cr_hl.1 Version 1.6 du 15/09/02 - .TH "HL" "1" "July 2015" "" "User Commands" .SH "NAME" hl - Colorize strings matching regular expressions .SH "SYNOPSIS" .PP -\fBhl\fP \fB [-h|-H|-V|-[eiuvdDEL1234][-[rgybmcwRGYBMCW] regexp ...][--config_name ...] ]\fP +\fBhl\fP \fB [-h|-H|-V|-[eiuvdDEL1234][-[[%.]rgybmcwRGYBMCW] regexp ...][--config_name ...] ]\fP .SH "DESCRIPTION" .PP @@ -81,6 +81,10 @@ Changes the brightness of all the following colors, until another brightness is .IP "\fB-4\fP " 10 color brightness (underscore). Changes the brightness of all the following colors, until another brightness is specified. +.IP "\fB-%c\fP " 10 +Specifies the beginning of a range colorized in color 'c'. +.IP "\fB-%.\fP " 10 +Specifies the end of the range colorized in color 'c'. .SH "PRIORITIES" A color specifier always has a higher priority than the one that follows. @@ -143,9 +147,16 @@ Colorize the output of the df command according to the configuration \fBdf\fP sp Example 6 : .B /sbin/ifconfig -a | hl --IP --MAC --eth - Colorize the output of the ifconfig command according to the configurations \fBIP\fP, \fBMAC\fP and \fBeth\fP specified in the configuration file. +.TP +Example 7 : +.B cal 2015 | hl -%3c 'January' -. '^$' + +Colorize the output of the \fBcal\fP command with the first three month in bright cyan : from the word \fBJanuary\fP to the first \fBempty line\fP. + + + .SH "FILES" .TP The \fBhl\fP command can use a configuration file named \fB$HOME/.hl.cfg\fP . @@ -213,7 +224,7 @@ hl : .EE .SH "MAN PAGE VERSION" -The version of this man page is 1.5. +The version of this man page is 1.6. It is compatible with hl version 1.42 and upper. .SH "AUTHOR" diff --git a/src/.hl.cfg b/src/.hl.cfg index d0fc918..78cef63 100644 --- a/src/.hl.cfg +++ b/src/.hl.cfg @@ -1,5 +1,5 @@ # -# @(#) [MB] cr_.hl.cfg Version 1.20 du 15/08/27 - +# @(#) [MB] cr_.hl.cfg Version 1.24 du 15/09/02 - # acl : @@ -272,6 +272,15 @@ hl_usage : -c '(-c .*)' -w '(-w .*)' +hosts : + -e + -b '#.*' + -1R '^([ ]+)[0-9.]' + -2g '^[ ]*\<((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))\>' + -3r '(([0-9]{1,3}\.){3}[0-9]{1,3})' + -3c '^[ ]*[0-9.]+[ ]+([^ ]+)' + -2y '^[ ]*[0-9.]+[ ]+[^ ]+(.+)' + ifconfig : -ei -m '^((eth|(vir)?br|vnet)[0-9.]*:[0-9]+)\>' @@ -348,6 +357,15 @@ netstat : -b '\<((127\.[01]\.[01]\.[01])|(0\.0\.0\.0))\>' -r '\<(([0-9]{1,3}\.){3}[0-9]{1,3})\>' +passwd : + -e + -c '^[^:]+' + -m '^[^:]+:([^:]+):' + -y '^[^:]+:[^:]+:([^:]+:[^:]+):' + -c '^([^:]*:){4}([^:]+)' + -g '^([^:]*:){5}([^:]+)' + -y '^([^:]*:){6}([^:]+)' + percent : -e -r '\<(100|9[5-9])%' @@ -362,6 +380,15 @@ ps_cpu : -c '00:00:0[1-9] .*' -b '00:00:00 .*' +rev_color_names : + -R 'red' + -G 'green' + -Y 'yellow' + -B 'blue' + -M 'magenta' + -C 'cyan' + -W 'white' + samba : -e -b '=|^[ ]*[;#].*' @@ -558,3 +585,108 @@ test : -R '^\(2\): .*(2)' -R '^\(2\): .*(1)' -r '^ 2 : (</red>) [^<]* (<red>.+</red>)' + +hi_red : + -e + -3 + -r '.+' + +hi_green : + -e + -3 + -g '.+' + +hi_yellow : + -e + -3 + -y '.+' + +hi_blue : + -e + -3 + -b '.+' + +hi_magenta : + -e + -3 + -m '.+' + +hi_cyan : + -e + -3 + -c '.+' + +hi_white : + -e + -3 + -w '.+' + +dim_red : + -e + -1 + -r '.+' + +dim_green : + -e + -1 + -g '.+' + +dim_yellow : + -e + -1 + -y '.+' + +dim_blue : + -e + -1 + -b '.+' + +dim_magenta : + -e + -1 + -m '.+' + +dim_cyan : + -e + -1 + -c '.+' + +dim_white : + -e + -1 + -w '.+' + +red : + -e + -2 + -r '.+' + +green : + -e + -2 + -g '.+' + +yellow : + -e + -2 + -y '.+' + +blue : + -e + -2 + -b '.+' + +magenta : + -e + -2 + -m '.+' + +cyan : + -e + -2 + -c '.+' + +white : + -e + -2 + -w '.+' diff --git a/src/cr_main.c b/src/cr_main.c index ccbd803..4d27643 100644 --- a/src/cr_main.c +++ b/src/cr_main.c @@ -20,7 +20,7 @@ * * File : cr_main.c * - * @(#) [MB] cr_main.c Version 1.50 du 15/08/27 - + * @(#) [MB] cr_main.c Version 1.51 du 15/09/02 - * * Functions in this file : * ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -643,7 +643,7 @@ int main(int argc, char *argv[]) break; case 'V': - fprintf(stderr, "%s: version %s\n", G.prgname, "1.50"); + fprintf(stderr, "%s: version %s\n", G.prgname, "1.51"); exit(1); break; @@ -714,7 +714,7 @@ int main(int argc, char *argv[]) ******************************************************************************/ void cr_usage(bool disp_config) { - fprintf(stderr, "%s: version %s\n", G.prgname, "1.50"); + fprintf(stderr, "%s: version %s\n", G.prgname, "1.51"); fprintf(stderr, "Usage: %s [-h|-H|-V|-[eiuvdDEL1234][-[rgybmcwRGYBMCW] regexp ...][--config_name ...] ]\n", G.prgname); fprintf(stderr, " -h : help\n"); @@ -1189,13 +1189,11 @@ void cr_disp_line(void) _c = G.line[_i]; if (_c == '\n' || (_c == 0 && G.newline)) { if (G.curr_col) { -//EC cr_end_color(G.curr_col); -//NC putc('\n', G.curr_col->out); + G.curr_col = NULL; } else { -//NC putc('\n', stdout); } } @@ -1206,8 +1204,8 @@ void cr_disp_line(void) /* Previous character was not in color ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ cr_start_color(_desc->col); -//SC putc(_c, _desc->col->out); + G.curr_col = _desc->col; } else { /* Previous character was in color @@ -1215,54 +1213,46 @@ void cr_disp_line(void) if (_desc-> col == G.curr_col) { /* No color change ~~~~~~~~~~~~~~~ */ -//NC putc(_c, G.curr_col->out); } else { /* Color change ~~~~~~~~~~~~ */ -//EC cr_end_color(G.curr_col); cr_start_color(_desc->col); -//SC putc(_c, _desc->col->out); + G.curr_col = _desc->col; } } } else { - /* Character was not in color - ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - if (G.curr_col == NULL) { - /* Previous character was not in color - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -//NC - putc(_c, stdout); - } - else { + /* Character is not in color + ~~~~~~~~~~~~~~~~~~~~~~~~~ */ + if (G.curr_col) { /* Previous character was in color ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -//EC cr_end_color(G.curr_col); -//NC putc(_c, G.curr_col->out); + G.curr_col = NULL; + } + else { + /* Previous character was not in color + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + putc(_c, stdout); } - } - G.curr_col = _desc->col; - if (_c == '\n') { - G.curr_col = NULL; } } +#if 0 if (G.newline) { if (G.curr_col) { -//EC cr_end_color(G.curr_col); } } +#endif _desc--; if (_desc->used) { -//EC cr_end_color(G.curr_col); } |