blob: 328e2d7d25582480fc55e1fb02940793bf91051f (
plain) (
blame)
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
#compdef zstyle
local curcontext="$curcontext" state context ostate line expl ctop
local nm=$compstate[nmatches] mesg
typeset -A opt_args
typeset -A styles
# Assoc array of styles; the values give the possible top-level
# contexts (currently c for completion, z for zftp or cz for both),
# followed by a colon, followed by a state to enter, empty if none.
styles=(
accept-exact c:bool
add-space c:bool
arguments c:
auto-description c:
break c:
completer c:completer
completions c:
condition c:
cursor c:cursor
disable-stat c:bool
domains c:
expand c:
file-patterns c:
format c:
glob c:
group-name c:
group-order c:tag
groups c:_groups
hidden c:bool
hosts c:_hosts
hosts-ports c:host-port
users-hosts-ports c:user-host-port
ignore-parents c:ignorepar
ignored-patterns c:
insert-unambiguous c:bool
last-prompt c:bool
list c:listwhen
list-arguments c:
list-colors c:
list-packed c:bool
list-rows-first c:bool
local c:
matcher c:
matcher-list c:
max-errors c:
menu c:boolauto
numbers c:bool
original c:bool
packageset c:packageset
path 'c:_path_files -/'
ports c:_ports
prefer-ignored c:bool
prefix-hidden c:bool
prefix-needed c:bool
prompt c:
remove-all-dups c:bool
single-ignored c:single-ignored
sort c:bool
tag-order c:tag
special-dirs c:sdirs
squeeze-slashes c:bool
stop c:stop
substitute c:
users c:_users
users-hosts c:user-host
verbose c:bool
word c:bool
chpwd z:bool
progress z:progress
remote_glob z:bool
titlebar z:bool
update z:
)
local taglist
taglist=(accounts all-files all-expansions arguments arrays
association-keys bookmarks builtins characters colors commands corrections
cursors cvs default descriptions devices directories directory-stack
displays expansions extensions files fonts functions globbed-files groups
history-words hosts indexes jobs keymaps keysyms local-directories
libraries limits manuals maps messages modifiers modules my-accounts
named-directories names nicknames options original other-accounts packages
parameters path-directories paths pods ports prefixes processes ps regex
sequences sessions signals strings tags targets types urls users values
warnings widgets windows zsh-options)
_arguments ':context:->contexts' ':style:->styles' '*:argument:->style-arg'
while [[ -n $state ]]; do
ostate=$state
state=
case "$ostate" in
contexts)
if _wanted contexts expl context; then
if [[ $PREFIX != :*: ]]; then
compadd -P : -S : "$expl[@]" completion zftp
elif [[ $PREFIX = :completion:* ]]; then
mesg=''
case "$PREFIX" in
:completion:[^:]#) mesg=function ;;
:completion:[^:]#:[^:]#) mesg=completer ;;
:completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;;
:completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;;
:completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;;
esac
[[ -n "$mesg" ]] && _message "$mesg"
fi
fi
;;
styles)
# Get the top-level context we're completing for, if any.
if [[ $words[2] = :(completion|zftp):* ]]; then
ctop=${words[2][2]}
else
ctop=cz
fi
_wanted styles expl style &&
compadd "$expl[@]" -M 'r:|-=* r:|=*' - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]}
;;
style-arg)
state="${styles[$words[3]]#*:}"
;;
bool)
_wanted values expl boolean &&
compadd "$expl[@]" true false
;;
boolauto)
_wanted values expl boolean &&
compadd "$expl[@]" true false auto select
;;
cursor)
if [[ "$words[2]" = *:completion:inc* ]]; then
_wanted values expl 'cursor positioning' &&
compadd "$expl[@]" complete key default
elif [[ "$words[2]" = *:completion::* ]]; then
_wanted values expl 'cursor positioning' &&
compadd "$expl[@]" true false
else
_wanted values expl 'cursor positioning' &&
compadd "$expl[@]" complete key default true false
fi
;;
completer)
_wanted values expl completer &&
compadd "$expl[@]" _complete _approximate _correct _match \
_expand _list _menu _oldlist
;;
user-host-port)
if [[ $PREFIX != *[@:]* ]]; then
_users -S @
elif [[ $PREFIX = *[@:]*[[@:]* ]]; then
compset -P 2 '*[:@]'
_ports
else
compset -P 1 '*[:@]'
_hosts -S :
fi
;;
host-port)
if [[ $PREFIX != *:* ]]; then
_hosts -S :
else
compset -P 1 '*:'
_ports
fi
;;
listwhen)
_wanted values expl 'when to list completions' &&
compadd "$expl[@]" always never sometimes
;;
packageset)
_wanted values expl 'default package set' &&
compadd "$expl[@]" available installed uninstalled
;;
progress)
_wanted values expl 'progress meter style' &&
compadd "$expl[@]" none bar percent
;;
sdirs)
_wanted values expl 'whether to complete . or ..' &&
compadd "$expl[@]" true false ..
;;
stop)
_wanted values expl 'when to insert matches' &&
compadd "$expl[@]" true false verbose
;;
tag)
_wanted tags expl tag && compadd "$expl[@]" - $taglist
;;
user-host)
if [[ $PREFIX = *[@:]* ]]; then
compset -P '*[@:]'
_hosts
else
_users -S @
fi
;;
ignorepar)
_wanted values expl 'which parents to ignore' &&
compadd "$expl[@]" parent pwd .. directory
;;
single-ignored)
_wanted values expl 'how to handle single alternate match' &&
compadd "$expl[@]" - show menu
;;
_*)
${=ostate}
;;
*)
;;
esac
done
[[ $compstate[nmatches] != $nm ]]
|