1CLIDE(1) User Contributed Perl Documentation CLIDE(1)
2
3
4
6 clide - color and style highlighting program for text
7
9 clide [options] [file1] [file2] [...fileN]
10
11 | clide [options] (STDIN through pipe)
12
13 clide [options] (STDIN. Use Ctrl-D to finish input)
14
16 clide is a program that allows you to colorize and add various display
17 altering attributes to text based on search patterns and expressions.
18 Currently the focus is on creating ANSI color and style escape codes
19 for use in terminal displays.
20
22 -h, --help - Show some terse help for the program
23
24 -e, --expression <expression>,<attributes>
25 Examples:
26 -e /searchpattern/,fg=red,bold
27 -e HTMLTAG,fg=blue,bg=yellow
28
29 -d, --definitionfile <file>
30
31 -f, --expressionfile <file>
32
33 --listcolors - Show a list of foreground and background colors
34 that can be used.
35
36 --liststyles - Show a list of styles that can be used (not all
37 of which may work on your display)
38
39 --listdefinitions - Show a list of predefined search expressions
40
41 --reverseprecedence, -r - Reverse the precedence order in which
42 expressions are run through.
43
44 --wf, --warmfuzzy "<message>" -
45 Send the developer a short message to let him know that you like this program.
46
48 FILE ARGUMENTS
49 One way to utilize clide is to process the contents of a file or
50 multiple files. This is done simply by passing the files as arguments
51 after the other options you wish to specify for matching expressions:
52
53 clide -e HTMLTAG,fg=yellow index.html
54
55 PIPELINES
56 Another way to use clide is by passing the output of one program into
57 it. You are sending the standard output (STDOUT) of one program to the
58 standard input (STDIN) of clide. Like this command that sends the
59 output of ls through clide, which colors lines that are directory
60 entries:
61
62 ls -l | clide -e /^d.*/,fg=blue,bold
63
64 SHELL ESCAPING
65 If you are creating more complex search patterns, you are probably
66 going to need to put quotes around the whole argument that is passed to
67 a -e option. This is because your shell will interpret certain
68 characters like (, ), $, &, [, ], etc. For example, this command uses
69 an expression that will change the percentage display of a filesystem
70 to red if it is 94% or more:
71
72 df -h | clide -e "/(100|9[4-9])%/,fg=red,bold"
73
74 But because ( ) is used in most shells as a subshell sequence, you have
75 to put quotes around the whole expression so that its not processed by
76 your shell.
77
79 Expressions can be specified on the command line using one or more -e
80 options. You can also use the -f option one or more times to specify
81 premade expression files.
82
83 PERL REGULAR EXPRESSIONS
84 clide works by passing the expression that you specify into a PERL
85 matching operator. This means that you can pass almost any valid PERL
86 regular expression to clide and it should work as expected.
87
88 The only limitation is in what flags you can pass to the search.
89 Currently, you can only pass a 'i' (case insensitive) and/or a 'g'
90 (global search) flag to the search expression. The multiline flag 'm'
91 is not supported.
92
93 For more information about perl regular expressions, see the pcre(1)
94 man page.
95
96 REGULAR EXPRESSION SEARCH
97 The basic way to tell clide what text you want to affect is to use the
98 regular expression search operator. This is passed to the -e option
99 along with a command seperated list of attributes to set.
100
101 clide -e /failed/i,fg=yellow,bg=red,bold
102
103 The above expression searches for the word failed (using the i option
104 after the second / means make the search case insensitive). It will
105 change the word failed to have a foreground color of bold yellow
106 (bright) and a background color of red.
107
108 PREDEFINED SEARCH PATTERNS
109 A list of helpful predefined search patterns is included with clide to
110 make pattern matching easier for the user. A list of the patterns is
111 available by running clide with the --listdefinitions option. You can
112 also put your own definitions in files and use the -f option to include
113 them.
114
115 Using a predefined search expression is simply a matter of using its
116 name for the first part of the -e argument, like this:
117
118 clide -e HOSTNAME,bold logfile.txt
119
120 WARNING: Predefined search patterns MUST use all uppercase names. In
121 the future clide may have other expression functions that start with
122 lower case letters and there needs to be a way to differentiate between
123 a pattern definition and an operation.
124
126 NOTE: The author would like to encourage you to put your expression and
127 definition files in a directory called .clide in your home directory.
128 Future versions of clide may make it easier to use these files if you
129 have them located in such a named directory.
130
131 EXPRESSION FILE
132 The expression file is pretty simple, you put each expression one per
133 line in exactly the same way that you would pass it to the -e option.
134 expression definitions can be used as the expressions themselves are
135 parsed after all the predefined expressions are read in. You can
136 include these files using the -f option.
137
138 So an expression file called microblogging might look like this:
139
140 HTMLTAG,fg=red,bg=black
141 URL,fg=yellow,bold,underline
142 TWITTERGROUP,fg=blue,bold
143 # Highlight some of my MB account names
144 /@(mkrenz|climagic|suso)/,fg=yellow,bg=blue,bold
145 TWITTERMENTION,fg=cyan
146 IDENTICAGROUP,fg=blue,bold
147
148 Then you'd use it like this:
149
150 twidge lsrecent | clide -f ~/.clide/microblogging
151
152 Comments can be made using a # character at the beginning of the line.
153
154 DEFINITION FILE
155 The definition file has a bit more of a format to it. Each line has two
156 columns seperated by whitespace. The first column is the name of the
157 definition in all uppercase letters. The second column is the search
158 expression starting with a forward slash and terminated by a forward
159 slash and one or more pcre flags (i or g)
160
161 # These are IPs I'm watching out for.
162 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
163 # Words I care about.
164 LOGINWORDS /(error|failed|failure|success|successful)/gi
165
166 Then just include the file using -d for each file you want to include.
167
168 Note that you don't need to escape or backslash as much in the searches
169 when you put them in a file as compared with when you specify the
170 pattern on the command line. Keep this in mind if you copy and paste
171 your expressions into a file.
172
174 Because one expression matching will actually alter the line in order
175 to add the escape sequences, matching expressions that are run later
176 may not match what the user expects them to match because the string
177 has changed. This is going to be fixed in a future release.
178
179 Currently clide can only work on 7-bit ASCII text. If it encounters a
180 line with upper 8-bit (binary) characters, it will simply print the
181 line with out doing any processing on it. If you're really curious as
182 to why, you can read the comments in the code or ask the author. A
183 future version of clide may not have this limitation.
184
185 Most terminal emulators and the console itself have some limitations as
186 to what they can display. Most of them don't support blinking text,
187 only some support dark mode, etc. This is not a limitation of clide, it
188 is your terminal software.
189
190 clide doesn't support multiline matching at this time.
191
193 pcre
194
196 If you like clide, you should let the author know by sending a short
197 message using the --warmfuzzy option, like this:
198
199 clide --warmfuzzy "I like clide"
200
201 This option makes an HTTP request to a website that will in turn let
202 the author know what you thought.
203
204 I included this option because I think that open source projects need
205 an easier way for users to give the developers a little reward for
206 their efforts.
207
209 This code is copyright 2010 by Mark Krenz under the terms of the GNU
210 GPL version 3. See the file COPYING that comes with clide for more
211 details.
212
214 You can find more information about clide at its website at
215
216 L<http://suso.suso.org/xulu/clide>
217
218 If you'd like to get involved with development in any way, please feel
219 free to contact the author.
220
222 clide was written by Mark Krenz <mark@suso.com>
223
224
225
226perl v5.10.1 2010-05-19 CLIDE(1)