Realized that recent changes deserve a new version number.
[selector.git] / selector.1
1 .TH "SELECTOR" "1.1.8" "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 cannot 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(es) 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--delete-regexp \fI<regexp>\fR
123 deletes in every line the portion matching the regexp
124 .TP
125 \fB-t \fI<title>\fR, \fB--title \fI<title>\fR
126 add a title in the modeline
127 .TP
128 \fB-r \fI<pattern>\fR, \fB--pattern \fI<pattern>\fR
129 set a pattern
130 .TP
131 \fB-c \fI<colors>\fR, \fB--colors \fI<colors>\fR
132 select the modeline and highlight color numbers with a color list of
133 the form
134
135 \fI<fg_modeline>,<bg_modeline>,<fg_highlight>,<bg_highlight>\fR
136 .TP
137 \fB-v\fR, \fB--inject-in-tty\fR
138 inject the selected line into the tty input buffer
139 .TP
140 \fB-w\fR, \fB--add-control-qs\fR
141 add ^Q between characters during tty injection to quote control characters
142 .TP
143 \fB-o \fI<filename>\fR, \fB--output-file \fI<filename>\fR
144 write the selected line into the specified file
145 .TP
146 \fB-s \fI<separator>\fR, \fB--pattern-separator \fI<separator>\fR
147 specify the character to separate the substrings in the search pattern
148 .TP
149 \fB-x \fI<separator>\fR, \fB--label-separator \fI<separator>\fR
150 specify the character to separate what to show to the user during the
151 selection from the line to return. If the provided separator is "\\n",
152 the lines to show to the user alternate with the lines to return
153 .TP
154 \fB-l \fI<number>\fR, \fB--number-of-lines \fI<number>\fR
155 specify the maximum number of lines to take into account
156
157 .SH "EXAMPLES"
158
159 To use selector to search into your bash history
160
161 .P
162 .nf
163 .B selector -q --bash <(history)
164
165 .fi
166 To show a list of directories and insert a cd command to the selected
167 one
168
169 .P
170 .nf
171 .B selector -v -x \(dq\\n\(dq <(find . -type d | awk \(aq{ print $0\(dq\\ncd \(dq$0 }\(aq)
172
173 .fi
174 To select a line in a long text and write the line number in /tmp/nb
175
176 .P
177 .nf
178 .B selector -o /tmp/nb -x \(dq\\n\(dq <(awk < something.txt \(aq{ print $0\(dq\\n\(dqNR }\(aq)
179
180 .SH "BUGS"
181
182 There are modeline display problems if the pattern is too long. This
183 program does not handle multibyte characters.
184
185 The \fB-v\fR option does not work on FreeBSD 8.0 since the TIOCSTI
186 ioctl request is broken.
187
188 .SH "AUTHOR"
189
190 Written by Francois Fleuret <francois@fleuret.org> and distributed
191 under the terms of the GNU General Public License version 3 as
192 published by the Free Software Foundation. This is free software: you
193 are free to change and redistribute it. There is NO WARRANTY, to the
194 extent permitted by law.