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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
COMMENT(!MOD!zsh/complist
Completion listing extensions.
!MOD!)
cindex(completion, listing)
cindex(completion, coloured listings)
The tt(zsh/complist) module offers two extensions to completion listings:
the ability to highlight matches in such a list and a different
style of menu-completion.
Whenever one of the parameters tt(ZLS_COLORS) or tt(ZLS_COLOURS) is set
and the tt(zsh/complist) module is loaded or linked into the shell,
completion lists will be colored. Note, however, that tt(complist) will
not automatically be loaded if it is not linked in: on systems with
dynamic loading, `tt(zmodload zsh/complist)' is required.
subsect(Parameters)
vindex(ZLS_COLORS)
vindex(ZLS_COLOURS)
The parameters tt(ZLS_COLORS) and tt(ZLS_COLOURS) describe how matches
are highlighted. To turn on highlighting an empty value suffices, in
which case all the default values given below will be used. The format of the
value of these parameters is the same as used by the GNU version of the
tt(ls) command: a colon-separated list of specifications of the form
`var(name)=var(value)'. The var(name) may be one of the following strings,
most of which specify file types for which the var(value) will be used. The
strings and their default values are:
startitem()
item(tt(no 0))(
for normal text (i.e. when displaying something other than a matched file)
)
item(tt(fi 0))(
for regular files
)
item(tt(di 32))(
for directories
)
item(tt(ln 36))(
for symbolic links
)
item(tt(pi 31))(
for named pipes (FIFOs)
)
item(tt(so 33))(
for sockets
)
item(tt(bd 44;37))(
for block devices
)
item(tt(cd 44;37))(
for character devices
)
item(tt(ex 35))(
for executable files
)
item(tt(mi) var(none))(
for non-existent file (default is the value defined for tt(fi))
)
item(tt(lc \e[))(
for the left code (see below)
)
item(tt(rc m))(
for the right code
)
item(tt(tc) var(0))(
for the character indicating the file type printed after filenames if
the tt(LIST_TYPES) option is set
)
item(tt(sp) var(0))(
for the spaces printed after matches to align the next column
)
item(tt(ec) var(none))(
for the end code
)
enditem()
Apart from these strings, the var(name) may also be an asterisk
(`tt(*)') followed by any string. The var(value) given for such a
string will be used for all files whose name ends with the string.
The var(name) may also be a equal sign (`tt(=)') followed by a
pattern. The var(value) given for this pattern will be used for all
matches (not only filenames) whose display string are matched by
the pattern. Definitions for both of these take precedence over the
values defined for file types and the form with the leading asterisk
takes precedence over the form with the leading equal sign.
The last form also allows to color separate parts of the displayed
strings using different colors. For this, the pattern has to use the
`tt((#b))' globbing flag and pairs of parentheses surrounding the
parts of the strings that are to be colored differently. In this case
the var(value) may consist of more than one color code separated by
equal signs. The first code will be used for all parts for which no
explicit code is specified and the following codes will be used for
the parts matched by the sub-patterns in parentheses. For example,
the specification `tt(=(#b)(?)*(?)=0=3=7)' will be used for all
matches which are at least two characters long and will make the use
the code `tt(3)' for the first character, `tt(7)' for the last
character and `tt(0)' for the rest.
All three forms of var(name) may be preceded by a pattern in
parentheses. If such a pattern is given, the var(value) will be used
only for matches in groups whose names are matched by the pattern
given in the parentheses. E.g. `tt((g*)m*=43)' says to highlight all
matches beginning with `tt(m)' in groups whose names begin with
`tt(g)' using the color code `tt(43)'. In case of the `tt(lc)',
`tt(rc)', and `tt(ec)' codes, the group pattern is ignored.
Note also that all patterns are tried in the order in which they
appear in the parameter value until the first one matches which is
then used.
When printing a match, the code prints the value of tt(lc), the value
for the file-type or the last matching specification with a `tt(*)',
the value of tt(rc), the string to display for the match itself, and
then the value of tt(ec) if that is defined or the values of tt(lc),
tt(no), and tt(rc) if tt(ec) is not defined.
The default values are ISO 6429 (ANSI) compliant and can be used on
vt100 compatible terminals such as tt(xterm)s. On monochrome terminals
the default values will have no visual effect.
If the shell function based completion system is used, these
parameters should not be set directly because the system controls them
itself. Instead, the tt(list-colors) style should be used (see
ifzman(the section `Completion System Configuration' in zmanref(zshcompsys))\
ifnzman(noderef(Completion System Configuration))\
).
subsect(Menu selection)
cindex(completion, selecting by cursor)
vindex(SELECTMIN)
tindex(menu-select)
The tt(zsh/complist) module also offers an alternative style of selecting
matches from a list, called menu-selection, which can be used if the
shell is set up to return to the last prompt after showing a
completion list (see the tt(ALWAYS_LAST_PROMPT) option in
ifzman(zmanref(zshoptions))\
ifnzman(noderef(Options))\
). It can be invoked directly by
the widget tt(menu-select) defined by the module. Alternatively,
the parameter tt(SELECTMIN) can be set to an integer, which give the
minimum number of matches that must be present before menu selection is
automatically turned on. This second method requires that menu completion
be started, either directly from a widget such as tt(menu-complete), or due
to one of the options tt(MENU_COMPLETE) or tt(AUTO_MENU) being set. If
tt(SELECTMIN) is set, but is 0, 1 or empty, menu selection will always be
started during an ambiguous menu completion.
When using the shell function based completion system, the
tt(SELECTMIN) parameter should not be used (like the tt(ZLS_COLORS)
and tt(ZLS_COLOURS) parameters described above). Instead, the tt(menu)
style should be used.
After menu-selection is started, the matches will be listed. The
matches to insert into the command line can be selected from this
list. In the list one match is highlighted using the value for tt(ma)
from the tt(ZLS_COLORS) or tt(ZLS_COLOURS) parameter. The default
value for this is `tt(7)' which forces the selected match to be
highlighted using standout mode on a vt100-compatible terminal. If
neither tt(ZLS_COLORS) nor tt(ZLS_COLOURS) is set, the same terminal
control sequence as for the `tt(%S)' escape in prompts is used.
The completion code sometimes decides not to show all of the matches
in the list. These hidden matches are either matches for which the
completion function which added them explicitly requested that they
not appear in the list (using the tt(-n) option of the tt(compadd)
builtin command) or they are matches which duplicate a string already
in the list (because they differ only in things like prefixes or
suffixes that are not displayed). In the list used for menu-selection,
however, even these matches are shown so that it is possible to select
them. To highlight such matches the tt(hi) and tt(du) capabilities in
the tt(ZLS_COLORS) and tt(ZLS_COLOURS) parameters are supported for
hidden matches of the first and second kind, respectively.
Selecting matches is done by moving the mark around using the zle movement
functions. The zle functions tt(send-break) and tt(accept-line) can be used
to leave menu-selection, leaving the match currently inserted into the line
in place. In the case of tt(accept-line), the match currently inserted
will be accepted and a new completion may be attempted.
Using tt(send-break) leaves menu-selection and continues with normal
menu-completion. The functions tt(accept-and-hold) and
tt(accept-and-menu-complete) can be used to accept the match currently
inserted and continue inserting matches from the same list. The
function tt(accept-and-infer-next-history) accepts the current match and
then tries completion with menu-selection again. In the case of
files this allows one to select a directory and immediately attempt to
complete files in it. Matches inserted in one of these ways can be removed
by invoking the tt(undo) function. Keys bound to one of
the completion functions will cycle to the next (or, in case of
tt(reverse-menu-complete), the previous) match, and the tt(redisplay) and
tt(clear-screen) functions work as usual without leaving
menu-selection.
Any other zle function leaves menu-selection and executes that function.
It is possible to make widgets in the above list do the same by using the
form of the widget with a `tt(.)' in front. For example, the widget
`tt(.accept-line)' has the effect of leaving menu selection and accepting
the entire command line.
During this selection the widget uses the keymap tt(menuselect). Any
key that is not defined in this keymap or that is bound to
tt(undefined-key) is looked up in the keymap currently selected. This
is used to ensure that the most important keys used during selection
have sensible default (namely the cursor keys, return, and TAB). However,
keys in the the tt(menuselect) keymap can be modified directly using the
tt(bindkey) builtin command (see
ifzman(zmanref(zshmodules))\
ifnzman(noderef(The zsh/zle Module))\
). For example, to make the return key leave menu-selection and
continue with normal menu-completion one can call
indent(tt(bindkey -M menuselect '^M' send-break))
after loading the tt(zsh/complist) module.
|