Cosmetics.
[selector.git] / selector.1
1 .TH "SELECTOR" "1.1.7" "February 2013" "Francois Fleuret" "User Commands"
2
3 \" This man page was written by Francois Fleuret <francois@fleuret.org>
4 \" and is distributed under a Creative Commons Attribution-Share Alike
5 \" 3.0 License.
6
7 .SH "NAME"
8
9 selector \- A simple command line utility for dynamic pattern selection
10
11 .SH "SYNOPSIS"
12
13 \fBselector\fP [\fIoptions\fR] [\fI<filename1>\fR [\fI<filename2>\fR ...]]
14
15 .SH "DESCRIPTION"
16
17 \fBselector\fP is a command line utility for interactive real-time
18 pattern matching. It reads the content of the specified files, and as
19 the user types a list of strings separated by ";" (or a regexp), the
20 display is updated in real time to show only the lines containing all
21 the said strings (or matching the regexp).
22
23 This command was mainly designed as a way to search efficiently in the
24 shell history, for which it is substantially better than the standard
25 readline ^R binding. With the -v option, it injects the selected line
26 into the tty input buffer, hence allowing the user to edit the line
27 and execute it as a standard command.
28
29 Selector is also a handy tool to test regexps, or to display menus
30 with many possible choices. For the latter, the -x option allows to
31 show different strings than the ones returned.
32
33 Note that because this is an interactive command, the standard input
34 can not be used as one of the input files.
35
36 .SH "USING SELECTOR IN BASH"
37
38 The selector command comes with a shell script for bash. If you add
39
40 .P
41 .nf
42 .B source bash-selector.sh --hist --cd
43
44 .fi
45 in your \fB~/.bashrc\fR, it will remap M-r to the smart history search,
46 and redefine \fBcd\fR so that M-c provides a smart cd history.
47
48 This script relies on readline being configured with the default
49 emacs-style key bindings. You may have to hack a bit if you want to
50 use it with the vi-style mode.
51
52 .SH "KEY BINDINGS"
53
54 Keys corresponding to ASCII codes between " " and "~" add a character
55 to the pattern string. The Backspace key, "^H" and "^?" delete the
56 character immediately on the left of the cursor, while the Delete key
57 and "^D" delete the character at cursor location.
58
59 The Left and Right cursor keys move the editing cursor
60 accordingly. The Up and Down cursor keys move the selected line one
61 entry at a time, and PageUp and PageDown move it by ten entries. The
62 Home and End key move to the top and the bottom of the list
63 respectively. The return key selects the current line and exits.
64
65 The keys "^A", "^E", "^U", and "^K" do somehow what they do in
66 readline, and you can exit selector without doing anything by either
67 interrupting the command with "^C" or by typing "^G" or the Escape
68 key.
69
70 The key "^R" switches between the multi-substring and the regexp
71 selection mode, and "^I" between the case-sensitive and
72 case-insensitive modes.
73
74 .SH "OPTIONS"
75 .TP
76 \fB-h\fR, \fB--help\fR
77 display help and exit
78 .TP
79 \fB-m\fR, \fB--monochrome\fR
80 force the monochrome mode
81 .TP
82 \fB-i\fR, \fB--revert-order\fR
83 revert the order of the lines
84 .TP
85 \fB-b\fR, \fB--remove-bash-prefix\fR
86 remove the numeric prefix from bash history
87 .TP
88 \fB-z\fR, \fB--remove-zsh-prefix\fR
89 remove the time prefix from zsh history
90 .TP
91 \fB-d\fR, \fB--remove-duplicates\fR
92 remove duplicated lines (note that you can have two different lines
93 with the same visible part if you use the -x option)
94 .TP
95 \fB-e\fR, \fB--regexp\fR
96 start in regexp mode
97 .TP
98 \fB-a\fR, \fB--case-sensitive\fR
99 start in case-sensitive mode
100 .TP
101 \fB-j\fR, \fB--show-long-lines\fR
102 print a long-line indicator at the end of truncated lines
103 .TP
104 \fB-y\fR, \fB--show-hits\fR
105 highlight the part(s) of each line which match the substrings or regexp
106 .TP
107 \fB-u\fR, \fB--upper-case-makes-case-sensitive\fR
108 using an upper case in the matching string makes the matching
109 case-sensitive
110 .TP
111 \fB-q\fR, \fB--no-beep\fR
112 make a flash instead of a beep when there is an edition error
113 .TP
114 \fB--\fR
115 state that all following arguments are filenames
116 .TP
117 \fB--bash\fR
118 standard setting for bash history search, same as
119
120 -b -i -d -v -w -l ${HISTSIZE}
121 .TP
122 \fB-t \fI<title>\fR, \fB--title \fI<title>\fR
123 add a title in the modeline
124 .TP
125 \fB-r \fI<pattern>\fR, \fB--pattern \fI<pattern>\fR
126 set a pattern
127 .TP
128 \fB-c \fI<colors>\fR, \fB--colors \fI<colors>\fR
129 select the modeline and highlight color numbers with a color list of
130 the form
131
132 \fI<fg_modeline>,<bg_modeline>,<fg_highlight>,<bg_highlight>\fR
133 .TP
134 \fB-v\fR, \fB--inject-in-tty\fR
135 inject the selected line into the tty input buffer
136 .TP
137 \fB-w\fR, \fB--add-control-qs\fR
138 add ^Q between characters during tty injection to quote control characters
139 .TP
140 \fB-o \fI<filename>\fR, \fB--output-file \fI<filename>\fR
141 write the selected line into the specified file
142 .TP
143 \fB-s \fI<separator>\fR, \fB--pattern-separator \fI<separator>\fR
144 specify the character to separate the substrings in the search pattern
145 .TP
146 \fB-x \fI<separator>\fR, \fB--label-separator \fI<separator>\fR
147 specify the character to separate what to show to the user during the
148 selection from the line to return. If the provided separator is "\\n",
149 the lines to show to the user alternate with the lines to return
150 .TP
151 \fB-l \fI<number>\fR, \fB--number-of-lines \fI<number>\fR
152 specify the maximum number of lines to take into account
153
154 .SH "EXAMPLES"
155
156 To use selector to search into your bash history
157
158 .P
159 .nf
160 .B
161
162 selector -q --bash <(history)
163
164 .fi
165 To show a list of directories and insert a cd command to the selected
166 one
167
168 .P
169 .nf
170 .B
171
172 selector -v -x \(dq\\n\(dq <(find . -type d | awk \(aq{ print $0\(dq\\ncd \(dq$0 }\(aq)
173
174 .fi
175 To select a line in a long text and write the line number in /tmp/nb
176
177 .P
178 .nf
179 .B
180
181 selector -o /tmp/nb -x \(dq\\n\(dq <(awk < something.txt \(aq{ print $0\(dq\\n\(dqNR }\(aq)
182
183 .SH "BUGS"
184
185 There are modeline display problems if the pattern is too long. This
186 program does not handle multibyte characters.
187
188 The \fB-v\fR option does not work on FreeBSD 8.0 since the TIOCSTI
189 ioctl request is broken.
190
191 .SH "AUTHOR"
192
193 Written by Francois Fleuret <francois@fleuret.org> and distributed
194 under the terms of the GNU General Public License version 3 as
195 published by the Free Software Foundation. This is free software: you
196 are free to change and redistribute it. There is NO WARRANTY, to the
197 extent permitted by law.