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 "July 2009" "Francois Fleuret" "User Commands"
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 dynamic string
18 selection. It reads the content of the specified files, and as the
19 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 in the shell
24 history, for which it is substantially more efficient than the
25 standard readline ^R binding. With the -v option, it injects the
26 selected line into the tty input buffer, hence allowing the user to
27 edit the line 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 .IP "\fB-h\fP" 10
62 display help and exits
63 .IP "\fB-m\fP" 10
64 force the monochrome mode
65 .IP "\fB-i\fP" 10
66 invert the order of the lines
67 .IP "\fB-b\fP" 10
68 remove the numeric prefix from bash history
69 .IP "\fB-z\fP" 10
70 remove the time prefix from zsh history
71 .IP "\fB-d\fP" 10
72 remove duplicated lines (note that you can have two different lines
73 with the same visible part if you use the -x option)
74 .IP "\fB-e\fP" 10
75 start in regexp mode
76 .IP "\fB-a\fP" 10
77 start in case sensitive mode
78 .IP "\fB-q\fP" 10
79 make a flash instead of a beep when there is an edition error
80 .IP "\fB--\fP" 10
81 state that all following arguments are filenames
82 .IP "\fB-t \fI<title>\fP" 10
83 add a title in the modeline
84 .IP "\fB-c \fI<fg_modeline> <bg_modeline> <fg_highlight> <bg_highlight>\fP" 10
85 select the modeline and highlight color numbers
86 .IP "\fB-v\fP" 10
87 inject the selected line into the tty input buffer
88 .IP "\fB-w\fP" 10
89 add ^Q between characters during tty injection to quote control characters
90 .IP "\fB-o \fI<output_filename>\fP" 10
91 write the selected line into the specified file
92 .IP "\fB-s \fI<pattern_separator>\fP" 10
93 specify the symbol to separate the substrings in the search pattern
94 .IP "\fB-x \fI<label_separator>\fP" 10
95 specify the symbol to separate what to show to the user during the
96 selection from the line to return
97 .IP "\fB-l \fI<max_number_of_lines>\fP" 10
98 specify the maximum number of lines to take into account
99 .IP "\fB-f \fI<input_filename>\fP" 10
100 specify a file to search into (option kept for compatibility reasons)
101
102 .SH "EXAMPLE"
103
104 To use selector to search into your bash history, you can use
105
106 .B selector -q -b -i -d -v -w -l ${HISTSIZE} <(history)
107
108 .SH "KEYBINDING IN BASH"
109
110 You can associate selector to a single key in bash by using the
111 command 'bind' in your bash initialization file. For instance, to
112 associate it to M-r (that is, the "Alt" and "r" key pressed together),
113 just add something like
114
115 bind '"\\C-[r":"\\C-a\\C-kselector -q -b -i -d -v -w -l ${HISTSIZE} <(history)\\C-m"'
116
117 in your
118 .IR ~/.bashrc .
119
120 Note that depending on the configuration of your system, the sequence
121 associated to the M-r key, which is here "C-[r", may differ. To figure
122 it out, simply press C-q followed by M-r in the console.
123
124 The control character "C-a" puts the cursor to the mostleft location,
125 "C-k" erases the current content of the readline buffer, and "C-m"
126 simulates the enter key.
127
128 .SH "BUGS"
129
130 There are modeline display problems if the pattern is too long. This
131 program does not handle multibyte characters.
132
133 .SH "AUTHOR"
134
135 The selector command was written by Francois Fleuret
136 <francois@fleuret.org> and is distributed under the terms of the GNU
137 General Public License version 3 as published by the Free Software
138 Foundation. This is free software: you are free to change and
139 redistribute it. There is NO WARRANTY, to the extent permitted by law.