Cosmetics.
[selector.git] / selector.1
1 .TH "SELECTOR" "1.1.7" "July 2012" "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 .SH "KEY BINDINGS"
49
50 Keys corresponding to ASCII codes between " " and "~" add a character
51 to the pattern string. The Backspace key, "^H" and "^?" delete the
52 character immediately on the left of the cursor, while the Delete key
53 and "^D" delete the character at cursor location.
54
55 The Left and Right cursor keys move the editing cursor
56 accordingly. The Up and Down cursor keys move the selected line one
57 entry at a time, and PageUp and PageDown move it by ten entries. The
58 Home and End key move to the top and the bottom of the list
59 respectively. The return key selects the current line and exits.
60
61 The keys "^A", "^E", "^U", and "^K" do somehow what they do in
62 readline, and you can exit selector without doing anything by either
63 interrupting the command with "^C" or by typing "^G" or the Escape
64 key.
65
66 The key "^R" switches between the multi-substring and the regexp
67 selection mode, and "^I" between the case-sensitive and
68 case-insensitive modes.
69
70 .SH "OPTIONS"
71 .TP
72 \fB-h\fR, \fB--help\fR
73 display help and exit
74 .TP
75 \fB-m\fR, \fB--monochrome\fR
76 force the monochrome mode
77 .TP
78 \fB-i\fR, \fB--revert-order\fR
79 revert the order of the lines
80 .TP
81 \fB-b\fR, \fB--remove-bash-prefix\fR
82 remove the numeric prefix from bash history
83 .TP
84 \fB-z\fR, \fB--remove-zsh-prefix\fR
85 remove the time prefix from zsh history
86 .TP
87 \fB-d\fR, \fB--remove-duplicates\fR
88 remove duplicated lines (note that you can have two different lines
89 with the same visible part if you use the -x option)
90 .TP
91 \fB-e\fR, \fB--regexp\fR
92 start in regexp mode
93 .TP
94 \fB-a\fR, \fB--case-sensitive\fR
95 start in case-sensitive mode
96 .TP
97 \fB-j\fR, \fB--show-long-lines\fR
98 print a long-line indicator at the end of truncated lines
99 .TP
100 \fB-y\fR, \fB--show-hits\fR
101 highlight the part(s) of each line which match the substrings or regexp
102 .TP
103 \fB-u\fR, \fB--upper-case-makes-case-sensitive\fR
104 using an upper case in the matching string makes the matching
105 case-sensitive
106 .TP
107 \fB-q\fR, \fB--no-beep\fR
108 make a flash instead of a beep when there is an edition error
109 .TP
110 \fB--\fR
111 state that all following arguments are filenames
112 .TP
113 \fB--bash\fR
114 standard setting for bash history search, same as
115
116 -b -i -d -v -w -l ${HISTSIZE}
117 .TP
118 \fB-t \fI<title>\fR, \fB--title \fI<title>\fR
119 add a title in the modeline
120 .TP
121 \fB-r \fI<pattern>\fR, \fB--pattern \fI<pattern>\fR
122 set a pattern
123 .TP
124 \fB-c \fI<colors>\fR, \fB--colors \fI<colors>\fR
125 select the modeline and highlight color numbers with a color list of
126 the form
127
128 \fI<fg_modeline>,<bg_modeline>,<fg_highlight>,<bg_highlight>\fR
129 .TP
130 \fB-v\fR, \fB--inject-in-tty\fR
131 inject the selected line into the tty input buffer
132 .TP
133 \fB-w\fR, \fB--add-control-qs\fR
134 add ^Q between characters during tty injection to quote control characters
135 .TP
136 \fB-o \fI<filename>\fR, \fB--output-file \fI<filename>\fR
137 write the selected line into the specified file
138 .TP
139 \fB-s \fI<separator>\fR, \fB--pattern-separator \fI<separator>\fR
140 specify the character to separate the substrings in the search pattern
141 .TP
142 \fB-x \fI<separator>\fR, \fB--label-separator \fI<separator>\fR
143 specify the character to separate what to show to the user during the
144 selection from the line to return. If the provided separator is "\\n",
145 the lines to show to the user alternate with the lines to return
146 .TP
147 \fB-l \fI<number>\fR, \fB--number-of-lines \fI<number>\fR
148 specify the maximum number of lines to take into account
149
150 .SH "EXAMPLES"
151
152 To use selector to search into your bash history
153
154 .P
155 .nf
156 .B
157
158 selector -q --bash <(history)
159
160 .fi
161 To show a list of directories and insert a cd command to the selected
162 one
163
164 .P
165 .nf
166 .B
167
168 selector -v -x \(dq\\n\(dq <(find . -type d | awk \(aq{ print $0\(dq\\ncd \(dq$0 }\(aq)
169
170 .fi
171 To select a line in a long text and write the line number in /tmp/nb
172
173 .P
174 .nf
175 .B
176
177 selector -o /tmp/nb -x \(dq\\n\(dq <(awk < something.txt \(aq{ print $0\(dq\\n\(dqNR }\(aq)
178
179 .SH "BUGS"
180
181 There are modeline display problems if the pattern is too long. This
182 program does not handle multibyte characters.
183
184 The \fB-v\fR option does not work on FreeBSD 8.0 since the TIOCSTI
185 ioctl request is broken.
186
187 .SH "AUTHOR"
188
189 Written by Francois Fleuret <francois@fleuret.org> and distributed
190 under the terms of the GNU General Public License version 3 as
191 published by the Free Software Foundation. This is free software: you
192 are free to change and redistribute it. There is NO WARRANTY, to the
193 extent permitted by law.