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