Automatic commit
[selector.git] / selector.1
1 .TH "SELECTOR" 1 "" "Francois Fleuret"
2 .SH "NAME"
3 selector \- A simple command line utility for dynamic pattern selection
4 .SH "SYNOPSIS"
5 .PP
6 \fBselector\fP [\fBoptions\fP] [<filename1> [<filename2> ...]]
7 .SH "DESCRIPTION"
8 .PP
9 \fBselector\fP is a command line utility for dynamic string
10 selection. As you type a list of strings separated by ";" or a regexp,
11 the display is updated in real time to show only the lines containing
12 all the said strings, or matching the regexp.
13
14 The main usage of selector is as an efficient search in the shell
15 command history. With the correct option, it will inject the selected
16 line into the virtual tty input buffer, hence allowing the user to
17 edit the line and execute it as a standard command.
18
19 Selector is also a good tool to test regexps, or a way to display
20 menus. The -x option allows to specify a label delimiter: the part of
21 each line before that character will appear during the selection, and
22 the part after that character will be returned.
23
24 .SH "KEYS"
25 .PP
26
27 Keys corresponding to ASCII codes between " " and "~" add a character
28 to the pattern string. The Backspace key, "^H" and "^?" delete the
29 character immediately on the left of the cursor, while the Delete key
30 and "^D" delete the character at cursor location.
31
32 The Left and Right cursor keys move the editing cursor
33 accordingly. The Up and Down cursor keys move the selected line one
34 entry at a time, and PageUp and PageDown move it by ten entries. The
35 Home and End key move to the top and the bottom of the list
36 respectively. The return key selects the current line and exits.
37
38 The keys "^A", "^E", "^U", and "^K" do somehow what they do in
39 readline, and you can exit selector without doing anything by either
40 interrupting the command with "^C" or by typing "^G" or the Escape
41 key.
42
43 The key "^R" switches between the multi-substring and the regexp
44 selection mode, and "^I" between the case-sensitive and
45 case-insensitive modes.
46
47 .SH "OPTIONS"
48 .IP "\fB-h\fP" 10
49 display help and exits
50 .IP "\fB-m\fP" 10
51 force the monochrome mode
52 .IP "\fB-i\fP" 10
53 invert the order of the lines
54 .IP "\fB-b\fP" 10
55 remove the numeric prefix from bash history
56 .IP "\fB-z\fP" 10
57 remove the time prefix from zsh history
58 .IP "\fB-d\fP" 10
59 remove duplicated lines (note that you can have two different lines
60 with the same visible part if you use the -x option)
61 .IP "\fB-e\fP" 10
62 start in regexp mode
63 .IP "\fB-a\fP" 10
64 start in case sensitive mode
65 .IP "\fB-q\fP" 10
66 make a flash instead of a beep when there is an edition error
67 .IP "\fB--\fP" 10
68 state that all following arguments are filenames
69 .IP "\fB-t <title>\fP" 10
70 add a title in the modeline
71 .IP "\fB-c <fg modeline> <bg modeline> <fg highlight> <bg highlight>\fP" 10
72 select the modeline and highlight color numbers
73 .IP "\fB-v\fP" 10
74 inject the selected line into the tty input buffer
75 .IP "\fB-w\fP" 10
76 add ^Q between characters during tty injection to quote control characters
77 .IP "\fB-o <output filename>\fP" 10
78 write the selected line into the specified file
79 .IP "\fB-s <pattern separator>\fP" 10
80 specify the symbol to separate the substrings in the search pattern
81 .IP "\fB-x <label separator>\fP" 10
82 specify the symbol to separate what to show to the user during the
83 selection from the line to return
84 .IP "\fB-l <max number of lines>\fP" 10
85 specify the maximum number of lines to take into account
86 .IP "\fB-f <input filename>\fP" 10
87 specify a file to search into (option kept for compatibility reasons)
88
89 .SH "EXAMPLE"
90
91 To use selector to search into your bash history, you can use
92
93 .B selector -q -b -i -d -v -w -l ${HISTSIZE} <(history)
94
95 .SH "KEY-BINDING IN BASH"
96
97 You can associate selector to a single key in bash by using the
98 command 'bind' in your bash initialization file. For instance, to
99 associate it to M-r (that is, the "Alt" and "r" key pressed together),
100 just add something like
101
102 bind '"\\C-[r":"\\C-a\\C-kselector -q -b -i -d -v -w -l ${HISTSIZE} <(history)\\C-m"'
103
104 in your ~/.bashrc.
105
106 Note that depending on the configuration of your system, the sequence
107 associated to the M-r key, which is here "C-[r", may differ. To figure
108 it out, simply press C-q followed by M-r in the console.
109
110 The control character "C-a" puts the cursor to the mostleft location,
111 "C-k" erases the current content of the readline buffer, and "C-m"
112 simulates the enter key.
113
114 .SH "BUGS"
115
116 There are modeline display problems if the pattern is too long. This
117 program does not handle multibyte characters.
118
119 .SH "AUTHOR"
120 .PP
121 Written by Francois Fleuret <francois@fleuret.org>, and distributed
122 under a Creative Commons Attribution-Share Alike 3.0 License.