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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# Gentoo Linux Bash Shell Command Completion
#
# Copyright 1999-2013 Gentoo Authors
# Distributed under the terms of the GNU General Public License, v2 or later
source "@helpersdir@/gentoo-common.sh"
#
# Bash completion for the Gentoo 'equery' command
#
_equery()
{
local cur prev mode portdir i j
portdir=$(_portdir)
mode="GLOBAL"
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Find out what we're currently doing here.
j=0
for i in "${COMP_WORDS[@]}"; do
if [[ $j -lt $COMP_CWORD ]]; then
j=$((j + 1))
case $i in
@(belongs|ch@(anges|eck)|dep@(ends|graph)|files|has?(use)|keywords|list|meta|size|uses|which|b|c|k|d|g|f|a|h|y|l|m|s|u|w))
mode=$i
;;
esac
fi
done
# Now get to work.
case $mode in
GLOBAL)
# Complete commands and global options.
case $cur in
-*)
COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
;;
*)
COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
;;
esac
;;
c?(hanges))
# Complete package name only if it is not yet supplied.
if [[ ${prev} == ${mode} ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help" -- $cur))
;;
*)
_pkgname -A $cur
;;
esac
else
case $cur in
*)
COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
;;
esac
fi
;;
f?(iles))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
# --filter=<list>: completion of the files types list
if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
return 0
fi
case $cur in
--f*)
# don't handle --filter= with others to avoid space after the "="
COMPREPLY=($(compgen -P "--filter=" \
-W "dir obj sym dev fifo path conf cmd doc man info"))
;;
-*)
COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
--type --tree -f --filter=" -- $cur))
;;
*)
# Only installed packages can have their files listed.
_pkgname -I $cur
;;
esac
fi
;;
a|has)
COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
--overlay-tree -p --portage-tree -F --format" -- $cur))
;;
y|keywords)
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case "${cur}" in
-*)
COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
--align -T --top-position -B --bold -C --color -O --overlays
-P --prefix -S --ignore-slot" -- $cur))
;;
*)
_pkgname -A $cur
;;
esac
fi
;;
l?(ist))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case "${cur}" in
-*)
COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
--binpkgs-missing -f --full-regex -m --mask-reason -I
--exclude-installed -o --overlay-tree -p --portage-tree -F
--format" -- $cur))
;;
*)
if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
_pkgname -A $cur
else
_pkgname -I $cur
fi
;;
esac
fi
;;
b?(elongs))
# Only complete if the previous entry on the command line is not
# a file name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
--early-out -n --name-only" -- $cur))
;;
*)
COMPREPLY=($(compgen -f -- $cur) \
$(compgen -d -S '/' -- $cur))
;;
esac
fi
;;
u?(ses))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
;;
*)
# Complete on all package names.
_pkgname -A $cur
;;
esac
fi
;;
w?(hich))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
;;
*)
# Complete on all package names.
_pkgname -A $cur
;;
esac
fi
;;
g|depgraph)
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
--no-useflags -l --linear --depth" -- $cur))
;;
*)
# Complete on all package names.
_pkgname -A $cur
;;
esac
fi
;;
d?(epends))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
--indirect --depth" -- $cur))
;;
*)
case $prev in
-a|--all-packages)
# Complete on all package names.
_pkgname -A $cur
;;
*)
# Complete on installed package names.
_pkgname -I $cur
;;
esac
;;
esac
fi
;;
m?(eta))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
_equery_meta $cur
fi
;;
k|check)
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
--full-regex -o --only-failures" -- ${cur}))
;;
*)
# Only installed packages can have their integrity verified.
_pkgname -I $cur
;;
esac
fi
;;
s?(ize))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "-h --help -b --bytes -f
--full-regex" -- $cur))
;;
*)
# Only installed packages can have their size calculated.
_pkgname -I $cur
;;
esac
fi
;;
h?(asuse))
# Only complete if the previous entry on the command line is not
# a package name.
if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
case $cur in
-*)
COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
;;
*)
local glob loc
[[ -f ${portdir}/profiles/use.desc ]] || return 0
[[ -f ${portdir}/profiles/use.local.desc ]] || return 0
glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
;;
esac
fi
;;
esac
return 0
} &&
complete -F _equery equery
# vim: ft=sh:et:ts=4:sw=4:tw=80
|