-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchoose.1
132 lines (112 loc) · 2.92 KB
/
choose.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.TH CHOOSE 1 2012-04-06 "choose 1.0" "User Commands"
.SH NAME
choose \- a shell menu
.SH SYNOPSIS
.B choose
.RI [ options ]
.RI < default_choice >
<choice_1> [choice_2] ...
.B choose
.RI [ options ]
.RI [ default_choice ]
< file_of_choices
command_which_print_choices |
.B choose
.RI [ options ]
.RI [ default_choice ]
Input choices can be arguments starting at the second one, a file with a choice per line, or lines from a piped command.
.SH DESCRIPTION
.B choose
allows an interactive choice on stderr among lines from stdin (or arguments) and returns the result on stdout.
multiple lines menu one line
---> choose --->
args / stdin TTY input / stderr stdout
It is nearly the same goal as the shell builtin
.B select
with fancy I/O more.
If there are many choices, the selected line is validated when the key ENTER is pressed.
The optional argument
.I default_choice
can preselect a line.
In cursor mode, it falls back to the first line if there is no matching default.
.SH OPTIONS
.TP
.B -h
help
.P
The different input behaviours are called modes.
.TP
.B -c
cursor mode (default)
.br
The selection can be moved with the keys UP and DOWN.
.TP
.B -n
numerated mode
.br
A number matching a list item can be entered.
.P
There are 2 styles for the selected line. It can be shown with an arrow or in a reversed font.
.TP
.B -r
reversed style (default)
.TP
.B -a
arrow style
.P
When the choice is done, the menu can disappeared (quiet), be replaced by the chosen line (default), or be kept as is (verbose).
.TP
.B -q
quiet = clean all on exit
.TP
.B -v
verbose = keep menu on exit
.P
If there is only one choice, it can be automatically chosen.
.TP
.B -s
single choice auto-validated
.P
The choices may be received from the standard input except if none or ignored.
.TP
.B -i
ignore standard input
.P
If you don't want it tampers your TTY with alternative settings and special characters, use
.RI - nav
options (numerated mode with arrow and keep verbose). It disables all "advanced" features.
.SH ENVIRONMENT
.TP
.B CHOOSE_MODE
can be "cursor" or "numerated" as default mode if options -c or -n are not used.
.TP
.B CHOOSE_STYLE
can be "reversed" or "arrow" as default style if options -r or -a are not used.
.TP
.B CHOOSE_INDENT
overrides the prefix of each line in cursor mode.
.TP
.B CHOOSE_ARROW
overrides the prefix of current line in arrow style.
.SH EXIT STATUS
.TP
.B 0
Successful execution
.TP
.B 1
Syntax error
.TP
.B 2
Interrupted by a signal
.SH BUGS
\(bu In cursor mode, long lines with non printable characters are smaller than the terminal width.
\(bu In numerated mode with default verbose, clearing may be wrong if there are long lines with non printable characters.
\(bu Long lists with more lines than the terminal height are only supported in numerated verbose mode.
.SH EXAMPLE
.nf \f(CW
# answer=$(choose -av '' yes no)
=> yes
no
# echo $answer
yes
.fi