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