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