clide (1) - Linux Manuals
clide: color and style highlighting program for text
NAME
clide - color and style highlighting program for text
SYNOPSIS
clide [options] [file1] [file2] [...fileN]| clide [options] (STDIN through pipe)
clide [options] (STDIN. Use Ctrl-D to finish input)
DESCRIPTION
clide is a program that allows you to colorize and add various display altering attributes to text based on search patterns and expressions. Currently the focus is on creating ANSI color and style escape codes for use in terminal displays.OPTIONS
-h, --help - Show some terse help for the program -e, --expression <expression>,<attributes> Examples: -e /searchpattern/,fg=red,bold -e HTMLTAG,fg=blue,bg=yellow -d, --definitionfile <file> -f, --expressionfile <file> --listcolors - Show a list of foreground and background colors that can be used. --liststyles - Show a list of styles that can be used (not all of which may work on your display) --listdefinitions - Show a list of predefined search expressions --reverseprecedence, -r - Reverse the precedence order in which expressions are run through. --wf, --warmfuzzy "<message>" - Send the developer a short message to let him know that you like this program.
EXAMPLES
FILE ARGUMENTS
One way to utilize clide is to process the contents of a file or multiple files. This is done simply by passing the files as arguments after the other options you wish to specify for matching expressions:
clide -e HTMLTAG,fg=yellow index.html
PIPELINES
Another way to use clide is by passing the output of one program into it. You are sending the standard output (STDOUT) of one program to the standard input (STDIN) of clide. Like this command that sends the output of ls through clide, which colors lines that are directory entries:
ls -l | clide -e /^d.*/,fg=blue,bold
SHELL ESCAPING
If you are creating more complex search patterns, you are probably going to need to put quotes around the whole argument that is passed to a -e option. This is because your shell will interpret certain characters like (, ), $, &, [, ], etc. For example, this command uses an expression that will change the percentage display of a filesystem to red if it is 94% or more:
df -h | clide -e "/(100|9[4-9])%/,fg=red,bold"
But because ( ) is used in most shells as a subshell sequence, you have to put quotes around the whole expression so that its not processed by your shell.
EXPRESSIONS
Expressions can be specified on the command line using one or more -e options. You can also use the -f option one or more times to specify premade expression files.PERL REGULAR EXPRESSIONS
clide works by passing the expression that you specify into a PERL matching operator. This means that you can pass almost any valid PERL regular expression to clide and it should work as expected.The only limitation is in what flags you can pass to the search. Currently, you can only pass a 'i' (case insensitive) and/or a 'g' (global search) flag to the search expression. The multiline flag 'm' is not supported.
For more information about perl regular expressions, see the pcre(1) man page.
REGULAR EXPRESSION SEARCH
The basic way to tell clide what text you want to affect is to use the regular expression search operator. This is passed to the -e option along with a command seperated list of attributes to set.
clide -e /failed/i,fg=yellow,bg=red,bold
The above expression searches for the word failed (using the i option after the second / means make the search case insensitive). It will change the word failed to have a foreground color of bold yellow (bright) and a background color of red.
PREDEFINED SEARCH PATTERNS
A list of helpful predefined search patterns is included with clide to make pattern matching easier for the user. A list of the patterns is available by running clide with the --listdefinitions option. You can also put your own definitions in files and use the -f option to include them.Using a predefined search expression is simply a matter of using its name for the first part of the -e argument, like this:
clide -e HOSTNAME,bold logfile.txt
WARNING: Predefined search patterns MUST use all uppercase names. In the future clide may have other expression functions that start with lower case letters and there needs to be a way to differentiate between a pattern definition and an operation.
FILE FORMATS
NOTE: The author would like to encourage you to put your expression and definition files in a directory called .clide in your home directory. Future versions of clide may make it easier to use these files if you have them located in such a named directory.EXPRESSION FILE
The expression file is pretty simple, you put each expression one per line in exactly the same way that you would pass it to the -e option. expression definitions can be used as the expressions themselves are parsed after all the predefined expressions are read in. You can include these files using the -f option.So an expression file called microblogging might look like this:
HTMLTAG,fg=red,bg=black URL,fg=yellow,bold,underline TWITTERGROUP,fg=blue,bold # Highlight some of my MB account names /@(mkrenz|climagic|suso)/,fg=yellow,bg=blue,bold TWITTERMENTION,fg=cyan IDENTICAGROUP,fg=blue,bold
Then you'd use it like this:
twidge lsrecent | clide -f ~/.clide/microblogging
Comments can be made using a # character at the beginning of the line.
DEFINITION FILE
The definition file has a bit more of a format to it. Each line has two columns seperated by whitespace. The first column is the name of the definition in all uppercase letters. The second column is the search expression starting with a forward slash and terminated by a forward slash and one or more pcre flags (i or g)
# These are IPs I'm watching out for. INTERESTINGIPS /\b(3\.14\.159\.26|206\.97\.64\.[29]|10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\b/g # Words I care about. LOGINWORDS /(error|failed|failure|success|successful)/gi
Then just include the file using -d for each file you want to include.
Note that you don't need to escape or backslash as much in the searches when you put them in a file as compared with when you specify the pattern on the command line. Keep this in mind if you copy and paste your expressions into a file.
BUGS AND LIMITATIONS
Because one expression matching will actually alter the line in order to add the escape sequences, matching expressions that are run later may not match what the user expects them to match because the string has changed. This is going to be fixed in a future release.Currently clide can only work on 7-bit ASCII text. If it encounters a line with upper 8-bit (binary) characters, it will simply print the line with out doing any processing on it. If you're really curious as to why, you can read the comments in the code or ask the author. A future version of clide may not have this limitation.
Most terminal emulators and the console itself have some limitations as to what they can display. Most of them don't support blinking text, only some support dark mode, etc. This is not a limitation of clide, it is your terminal software.
clide doesn't support multiline matching at this time.
WARMFUZZY
If you like clide, you should let the author know by sending a short message using the --warmfuzzy option, like this:
clide --warmfuzzy "I like clide"
This option makes an HTTP request to a website that will in turn let the author know what you thought.
I included this option because I think that open source projects need an easier way for users to give the developers a little reward for their efforts.
COPYRIGHT
This code is copyright 2010 by Mark Krenz under the terms of the GNU GPL version 3. See the file COPYING that comes with clide for more details.MORE INFO
You can find more information about clide at its website at
L<http://suso.suso.org/xulu/clide>
If you'd like to get involved with development in any way, please feel free to contact the author.
AUTHOR
clide was written by Mark Krenz <mark [at] suso.com>