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