Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
Date: Sun, 31 Aug 2014 21:19:11
Message-Id: 1409512737.1781d5b81021858db447d4c63f68e081e320fd00.mgorny@gentoo
1 commit: 1781d5b81021858db447d4c63f68e081e320fd00
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 31 19:18:57 2014 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 31 19:18:57 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-bashcomp.git;a=commit;h=1781d5b8
7
8 Split completions by completed command.
9
10 ---
11 completions/browser-config | 31 +
12 completions/distcc-config | 41 ++
13 completions/ebuild | 34 +
14 completions/ekeyword | 46 ++
15 completions/emerge | 410 +++++++++++
16 completions/epkginfo | 28 +
17 completions/epm | 48 ++
18 completions/equery | 280 ++++++++
19 completions/euse | 60 ++
20 completions/gcc-config | 45 ++
21 completions/gentoo | 1652 --------------------------------------------
22 completions/glsa-check | 33 +
23 completions/java-config | 158 +++++
24 completions/metagen | 30 +
25 completions/portageq | 87 +++
26 completions/rc | 21 +
27 completions/rc-service | 111 +++
28 completions/rc-status | 28 +
29 completions/rc-update | 40 ++
30 completions/revdep-rebuild | 55 ++
31 completions/splat | 33 +
32 completions/webapp-config | 169 +++++
33 22 files changed, 1788 insertions(+), 1652 deletions(-)
34
35 diff --git a/completions/browser-config b/completions/browser-config
36 new file mode 100644
37 index 0000000..158ca42
38 --- /dev/null
39 +++ b/completions/browser-config
40 @@ -0,0 +1,31 @@
41 +# Gentoo Linux Bash Shell Command Completion
42 +#
43 +# Copyright 1999-2013 Gentoo Foundation
44 +# Distributed under the terms of the GNU General Public License, v2 or later
45 +
46 +#
47 +# browser-config completion command
48 +#
49 +_browserconfig()
50 +{
51 + local cur prev
52 + COMPREPLY=()
53 + cur="${COMP_WORDS[COMP_CWORD]}"
54 + prev="${COMP_WORDS[COMP_CWORD-1]}"
55 + if [[ ${COMP_CWORD} -eq 1 ]]; then
56 + COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
57 + elif [[ "${prev}" == "-b" ]]; then
58 + COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
59 + elif [[ "${prev}" == "-m" ]]; then
60 + COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
61 + if [[ -z "${COMPREPLY}" ]]; then
62 + COMPREPLY=''
63 + fi
64 + else
65 + unset COMPREPLY
66 + fi
67 + return 0
68 +} &&
69 +complete -F _browserconfig browser-config
70 +
71 +# vim: ft=sh:et:ts=4:sw=4:tw=80
72
73 diff --git a/completions/distcc-config b/completions/distcc-config
74 new file mode 100644
75 index 0000000..41c315f
76 --- /dev/null
77 +++ b/completions/distcc-config
78 @@ -0,0 +1,41 @@
79 +# Gentoo Linux Bash Shell Command Completion
80 +#
81 +# Copyright 1999-2013 Gentoo Foundation
82 +# Distributed under the terms of the GNU General Public License, v2 or later
83 +
84 +#
85 +# distcc-config completion command
86 +#
87 +_distccconfig()
88 +{
89 + local cur curword numwords opts
90 + COMPREPLY=()
91 + cur="${COMP_WORDS[COMP_CWORD]}"
92 + numwords=${#COMP_WORDS[*]}
93 + curword=${COMP_CWORD}
94 + if [[ ${numwords} -gt 3 ]]; then
95 + unset COMPREPLY
96 + return 0
97 + fi
98 + if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
99 + if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
100 + opts="--get-hosts \
101 + --get-verbose \
102 + --get-log \
103 + --set-hosts \
104 + --set-verbose \
105 + --set-log \
106 + --add-path \
107 + --no-path"
108 + else
109 + opts=""
110 + fi
111 + else
112 + opts=""
113 + fi
114 + COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
115 + return 0
116 +} &&
117 +complete -F _distccconfig distcc-config
118 +
119 +# vim: ft=sh:et:ts=4:sw=4:tw=80
120
121 diff --git a/completions/ebuild b/completions/ebuild
122 new file mode 100644
123 index 0000000..cd6e17e
124 --- /dev/null
125 +++ b/completions/ebuild
126 @@ -0,0 +1,34 @@
127 +# Gentoo Linux Bash Shell Command Completion
128 +#
129 +# Copyright 1999-2013 Gentoo Foundation
130 +# Distributed under the terms of the GNU General Public License, v2 or later
131 +
132 +#
133 +# ebuild completion command
134 +#
135 +_ebuild()
136 +{
137 + local cur opts
138 + COMPREPLY=()
139 + cur="${COMP_WORDS[COMP_CWORD]}"
140 +
141 + opts="help setup clean fetch digest manifest unpack compile test preinst \
142 + install postinst qmerge merge unmerge prerm postrm config package rpm \
143 + configure prepare"
144 +
145 + if [[ $COMP_CWORD -eq 1 ]] ; then
146 + COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
147 + $(compgen -d -- ${cur}) \
148 + $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
149 +
150 + elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
151 + COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
152 +
153 + elif [[ $COMP_CWORD -ge 2 ]] ; then
154 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
155 + fi
156 + return 0
157 +} &&
158 +complete -o filenames -F _ebuild ebuild
159 +
160 +# vim: ft=sh:et:ts=4:sw=4:tw=80
161
162 diff --git a/completions/ekeyword b/completions/ekeyword
163 new file mode 100644
164 index 0000000..3bf3006
165 --- /dev/null
166 +++ b/completions/ekeyword
167 @@ -0,0 +1,46 @@
168 +# Gentoo Linux Bash Shell Command Completion
169 +#
170 +# Copyright 1999-2013 Gentoo Foundation
171 +# Distributed under the terms of the GNU General Public License, v2 or later
172 +
173 +source "@helpersdir@/gentoo-common.sh"
174 +
175 +#
176 +# ekeyword completion
177 +#
178 +
179 +_ekeyword()
180 +{
181 + local cur portdir archl_s archl_u archl_r archl_m arch
182 + COMPREPLY=()
183 + cur="${COMP_WORDS[COMP_CWORD]}"
184 + portdir=$(_portdir)
185 +
186 + [[ -f ${portdir}/profiles/arch.list ]] || return 0
187 +
188 + for arch in all $(< ${portdir}/profiles/arch.list) ; do
189 + archl_m="${archl_m} -${arch}"
190 + archl_u="${archl_u} ~${arch}"
191 + archl_r="${archl_r} ^${arch}"
192 + archl_s="${archl_s} ${arch}"
193 + done
194 +
195 + case ${cur} in
196 + -*)
197 + COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
198 + ;;
199 + ~*)
200 + COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
201 + ;;
202 + ^*)
203 + COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
204 + ;;
205 + *)
206 + COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
207 + _filedir 'ebuild'
208 + ;;
209 + esac
210 +} &&
211 +complete -o filenames -F _ekeyword ekeyword
212 +
213 +# vim: ft=sh:et:ts=4:sw=4:tw=80
214
215 diff --git a/completions/emerge b/completions/emerge
216 new file mode 100644
217 index 0000000..63c02b4
218 --- /dev/null
219 +++ b/completions/emerge
220 @@ -0,0 +1,410 @@
221 +# Gentoo Linux Bash Shell Command Completion
222 +#
223 +# Copyright 1999-2013 Gentoo Foundation
224 +# Distributed under the terms of the GNU General Public License, v2 or later
225 +
226 +source "@helpersdir@/gentoo-common.sh"
227 +
228 +#
229 +# emerge completion command
230 +#
231 +_emerge()
232 +{
233 + local c cur prev curword numwords opts cond prepend
234 + local words stophere i x
235 + local action actionpos sysactions pkgpos
236 + local portdir=$(_portdir -o)
237 + COMPREPLY=()
238 + cur="${COMP_WORDS[COMP_CWORD]}"
239 + prev="${COMP_WORDS[COMP_CWORD-1]}"
240 + numwords=${#COMP_WORDS[*]}
241 + curword=${COMP_CWORD}
242 + opts=''
243 +
244 + if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
245 + COMPREPLY=($(compgen -f -- ${cur}))
246 + return 0
247 + fi
248 +
249 + # find action
250 + for x in ${COMP_LINE} ; do
251 + if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
252 + [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
253 + then
254 + action=${x}
255 + break
256 + fi
257 + done
258 +
259 + if [[ -n ${action} ]]; then
260 + for ((i = 0; i < ${numwords}; i++ )); do
261 + if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
262 + actionpos=${i}
263 + pkgpos=$((actionpos + 1))
264 + break
265 + fi
266 + done
267 +
268 + if [[ ${action} == -* && ${action} != --* ]] ; then
269 + case "${action}" in
270 + -*C*) action='--unmerge' ;;
271 + -*P*) action='--prune' ;;
272 + -*c*) action='--clean' ;;
273 + -*s*) action='--search' ;;
274 + esac
275 + fi
276 + else
277 + for ((i = 1; i < ${numwords}; i++ )); do
278 + if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
279 + pkgpos=${i}
280 + break
281 + fi
282 + done
283 + [[ -z ${pkgpos} ]] && pkgpos=${numwords}
284 + fi
285 +
286 + # Handle special cases.
287 + if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
288 + [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
289 + then
290 + unset COMPREPLY
291 + return 0
292 + elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
293 + unset COMPREPLY
294 + [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
295 + return 0
296 + fi
297 +
298 + # Complete on options.
299 + if [[ ${cur} == -* ]]; then
300 + # If a resume option was specified, it needs special handling.
301 + if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
302 + if [[ ${cur} == --* ]]; then
303 + opts="--ask --pretend --resume --skipfirst"
304 + elif [[ ${cur} == -* ]]; then
305 + [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
306 + fi
307 + elif [[ ${cur} == --* ]]; then
308 + # Complete on long options.
309 + opts="--alphabetical --ask \
310 + --buildpkg --buildpkgonly \
311 + --changelog --clean --color=y --color=n --columns --complete-graph --config \
312 + --debug --deep --depclean \
313 + --emptytree \
314 + --fetch-all-uri --fetchonly \
315 + --getbinpkg --getbinpkgonly \
316 + --ignore-default-opts --info \
317 + --jobs= \
318 + --keep-going \
319 + --metadata \
320 + --newuse --noconfmem --nodeps --noreplace --nospinner \
321 + --oneshot --onlydeps \
322 + --pretend --prune \
323 + --quiet \
324 + --reinstall=changed-use --regen \
325 + --search \
326 + --sync \
327 + --tree \
328 + --unmerge --update --upgradeonly --usepkg --usepkgonly \
329 + --verbose \
330 + --with-bdeps=y --with-bdeps=n"
331 + if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
332 + opts="${opts} --help --resume --searchdesc --version"
333 + fi
334 + elif [[ ${cur} == -* ]]; then
335 + # Complete on short options.
336 + opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
337 + if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
338 + opts="${opts} -h -S -V"
339 + fi
340 + if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
341 + opts="${opts} -C -P -c -s"
342 + fi
343 + fi
344 +
345 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
346 +
347 + # NOTE: This slows things down!
348 + # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
349 + # This removes any options from the list of completions that have
350 + # already been specified on the command line.
351 + COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
352 + (while read -d ' ' i; do
353 + [[ -z ${i} ]] && continue
354 + # flatten array with spaces on either side,
355 + # otherwise we cannot grep on word boundaries of
356 + # first and last word
357 + COMPREPLY=" ${COMPREPLY[@]} "
358 + # remove word from list of completions
359 + COMPREPLY=(${COMPREPLY/ ${i%% *} / })
360 + done
361 + echo ${COMPREPLY[@]})))
362 +
363 + return 0
364 + fi # options
365 +
366 + # Stop completion if a special case is encountered.
367 + if [[ ${action} =~ (system|world) ]] || \
368 + [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
369 + then
370 + unset COMPREPLY
371 + return 0
372 + fi
373 +
374 + # Complete on installed packages when unmerging.
375 + if [[ "${action}" == '--unmerge' ]]; then
376 + if [[ -n "${cur}" ]] ; then
377 + if [[ "${cur}" == */* ]]; then
378 + words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
379 + else
380 + words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
381 +
382 + local n=0
383 + for i in ${words} ; do
384 + [[ ${i} == ${cur}* ]] && n=$((n+1))
385 + done
386 +
387 + if [[ ${n} -eq 1 ]] ; then
388 + words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
389 + fi
390 + fi
391 + COMPREPLY=($(for i in ${words} ; do \
392 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
393 + done))
394 + else
395 + COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
396 + fi
397 +
398 + [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
399 + return 0
400 + fi
401 +
402 + # Check for conditional.
403 + cond="${cur%%[A-Za-z0-9]*}"
404 + cur="${cur:${#cond}}"
405 + if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
406 + prepend="-P ${cond:1}"
407 + c="${cond:1}"
408 + else
409 + c="${cond}"
410 + fi
411 +
412 + # Handle cases where a conditional is specified.
413 + if [[ -n "${cond}" ]]; then
414 + if [[ -n "${cur}" ]]; then
415 + if [[ ${cur} == */* ]]; then
416 + if [[ ${cur} == *-[0-9]* ]] ; then
417 + words="$(\
418 + for pd in ${portdir} ; do \
419 + builtin cd ${pd} ; \
420 + local cat="${cur%/*}" ; \
421 + local pkg="$(echo ${cur%-[0-9]*})" ; \
422 + pkg="${pkg##*/}" ; \
423 + for x in ${cat}/${pkg}/*.ebuild ; do \
424 + [[ -f ${x} ]] || continue ; \
425 + x="${x/${pkg}\/}" ; \
426 + echo "${x%*.ebuild}" ; \
427 + done ; \
428 + done)"
429 + else
430 + words="$(\
431 + for pd in ${portdir} ; do \
432 + builtin cd ${pd}; \
433 + compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
434 + done)"
435 + fi
436 +
437 + local w
438 + for x in $words ; do
439 + w="${x}\n${w}"
440 + done
441 +
442 + words=$(echo -ne ${w} | sort | uniq)
443 + COMPREPLY=( ${words} )
444 +
445 + # Complete on the specific versions (if appropriate).
446 + # TODO - see if we can use _pkgname
447 + if [[ ${#COMPREPLY[@]} -le 1 ]]; then
448 + COMPREPLY=($(
449 + for pd in ${portdir}; do
450 + if [[ -d ${pd}/metadata/md5-cache ]]; then
451 + builtin cd ${pd}/metadata/md5-cache
452 + compgen ${prepend} -G "${cur}*" -- "${cur}"
453 + elif [[ -d ${pd}/metadata/cache ]]; then
454 + builtin cd ${pd}/metadata/cache
455 + compgen ${prepend} -G "${cur}*" -- "${cur}"
456 + else
457 + builtin cd ${pd}
458 + local cat="${cur%/*}"
459 + local pkg="$(echo ${cur%-[0-9]*}*)"
460 + pkg="${pkg##*/}"
461 + for x in ${cat}/${pkg}/*.ebuild; do
462 + [[ -f "${x}" ]] || continue
463 + x="${x/${pkg}\/}"
464 + if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
465 + echo "${c}${x%*.ebuild}"
466 + else
467 + echo "${x%*.ebuild}"
468 + fi
469 + done
470 + fi
471 + done
472 + ))
473 + else
474 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
475 + fi
476 + else
477 + words="$(\
478 + for pd in ${portdir} ; do \
479 + builtin cd ${pd} ; \
480 + compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
481 + done)"
482 +
483 + local w
484 + for x in words ; do
485 + w="${x}\n${w}"
486 + done
487 +
488 + COMPREPLY=($(echo -e ${w} | uniq))
489 + [[ ${#COMPREPLY[@]} = 1 ]] && \
490 + COMPREPLY=($(\
491 + for pd in ${portdir} ; do \
492 + builtin cd ${pd} ; \
493 + compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
494 + done))
495 + fi
496 + else
497 + words="$(\
498 + for pd in ${portdir} ; do \
499 + builtin cd ${pd}; \
500 + compgen -G "*-*"; \
501 + done)"
502 + COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
503 + fi
504 +
505 + # If all else fails, try to complete on package names without the
506 + # category being specified.
507 + if [[ -z "${COMPREPLY}" ]]; then
508 + words="$(\
509 + for pd in ${portdir} ; do \
510 + builtin cd ${pd}; \
511 + for i in *-*/${cur}*; do \
512 + [[ -d $i ]] && echo ${i##*/}; \
513 + done ; \
514 + done)"
515 +
516 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
517 +
518 + if [[ ${#COMPREPLY[@]} -le 1 ]]; then
519 + # Now complete on the specific versions.
520 + words="$(
521 + for pd in ${portdir}; do
522 + if [[ -d ${pd}/metadata/md5-cache ]]; then
523 + builtin cd ${pd}/metadata/md5-cache
524 + for i in */${cur}*; do
525 + [[ -f $i ]] && echo ${i##*/}
526 + done
527 + elif [[ -d ${pd}/metadata/cache ]]; then
528 + builtin cd ${pd}/metadata/cache
529 + for i in */${cur}*; do
530 + [[ -f $i ]] && echo ${i##*/}
531 + done
532 + fi
533 + done
534 + )"
535 + COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
536 + fi
537 + fi
538 + return 0
539 + fi
540 +
541 + # Complete on packages.
542 + #
543 + # Only allow these actions if no packages have been specified.
544 + #
545 + # TODO: This doesn't block these actions if no categories are
546 + # specified. Please fix me.
547 + #
548 + # e.g. emerge -a gentoo-dev-sources
549 + #
550 + # will still allow system and world actions to be specified,
551 + # as opposed to
552 + #
553 + # emerge -a sys-kernel/gentoo-dev-sources
554 + #
555 + if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
556 + sysactions=$'\n'"system"$'\n'"world"
557 + else
558 + sysactions=''
559 + fi
560 +
561 + if [[ -n "${cur}" ]] ; then
562 + if [[ ${cur} == */* ]] ; then
563 + words=$(\
564 + for pd in ${portdir} ; do \
565 + builtin cd ${pd}; \
566 + compgen -X "*metadata.xml" -G "${cur}*" ; \
567 + done)"${sysactions}"
568 + else
569 + local ww=$(\
570 + for pd in ${portdir} ; do \
571 + builtin cd ${pd} ; \
572 + compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
573 + done)"${sysactions}"
574 + # complete on virtuals
575 + ww="${ww} $(\
576 + for pd in ${portdir} ; do \
577 + if [[ -d ${pd}/profiles ]] ; then
578 + find ${pd}/profiles -name virtuals -exec \
579 + sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
580 + sort -u
581 + fi ; \
582 + done)"
583 +
584 + local w
585 + for x in ${ww} ; do w="${x}\n${w}" ; done
586 +
587 + words=$(echo -e ${w} | sort -u)
588 +
589 + local n=0
590 + for i in ${words} ; do
591 + [[ ${i} == ${cur}* ]] && n=$((n+1))
592 + done
593 +
594 + if [[ ${n} -eq 1 ]] ; then
595 + words=$(for pd in ${portdir} ; do \
596 + builtin cd ${pd} ; \
597 + compgen -G "*-*/*" ; \
598 + done)"${sysactions}"
599 + fi
600 + fi
601 + COMPREPLY=($(for i in ${words} ; do \
602 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
603 + done))
604 + else
605 + words="$(\
606 + for pd in ${portdir} ; do \
607 + builtin cd ${pd} ; \
608 + compgen -S '/' -G "*-*" ; \
609 + done)""${sysactions}"
610 + COMPREPLY=($(compgen -W "${words}" -- ${cur}))
611 + fi
612 +
613 + # If all else fails, try to complete on package names without the
614 + # category being specified.
615 + if [[ -z "${COMPREPLY}" ]]; then
616 + words="$(\
617 + for pd in ${portdir} ; do \
618 + builtin cd ${pd}; \
619 + for i in [a-z]*-[a-z0-9]*/${cur}*; do \
620 + [[ -d $i ]] && echo ${i##*/}; \
621 + done ; \
622 + done)"
623 + COMPREPLY=($(compgen -W "${words}" -- ${cur}))
624 + fi
625 +
626 + return 0
627 +} &&
628 +complete -o filenames -F _emerge emerge
629 +
630 +# vim: ft=sh:et:ts=4:sw=4:tw=80
631
632 diff --git a/completions/epkginfo b/completions/epkginfo
633 new file mode 100644
634 index 0000000..34c81f3
635 --- /dev/null
636 +++ b/completions/epkginfo
637 @@ -0,0 +1,28 @@
638 +# Gentoo Linux Bash Shell Command Completion
639 +#
640 +# Copyright 1999-2013 Gentoo Foundation
641 +# Distributed under the terms of the GNU General Public License, v2 or later
642 +
643 +source "@helpersdir@/gentoo-common.sh"
644 +
645 +#
646 +# epkginfo completion
647 +#
648 +
649 +_epkginfo()
650 +{
651 + local cur prev
652 + cur="${COMP_WORDS[COMP_CWORD]}"
653 + prev="${COMP_WORDS[COMP_CWORD-1]}"
654 +
655 + # Only complete if the previous entry on the command line is not
656 + # a package name.
657 + if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
658 + _equery_meta $cur
659 + fi
660 +
661 + return 0
662 +} &&
663 +complete -F _epkginfo epkginfo
664 +
665 +# vim: ft=sh:et:ts=4:sw=4:tw=80
666
667 diff --git a/completions/epm b/completions/epm
668 new file mode 100644
669 index 0000000..e8a8caa
670 --- /dev/null
671 +++ b/completions/epm
672 @@ -0,0 +1,48 @@
673 +# Gentoo Linux Bash Shell Command Completion
674 +#
675 +# Copyright 1999-2013 Gentoo Foundation
676 +# Distributed under the terms of the GNU General Public License, v2 or later
677 +
678 +source "@helpersdir@/gentoo-common.sh"
679 +
680 +_epm() {
681 + local cur prev opts
682 + COMPREPLY=()
683 + cur="${COMP_WORDS[COMP_CWORD]}"
684 + prev="${COMP_WORDS[COMP_CWORD]}"
685 + opts="-q --query -V -y --verify -e --erase --help"
686 +
687 + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
688 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
689 + return 0
690 + fi
691 +
692 + case "${prev}" in
693 + --help)
694 + COMPREPLY=()
695 + ;;
696 + -q|--query)
697 + _pkgname -I ${cur}
698 + COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
699 + ;;
700 + *)
701 + local x all=0 file=0
702 + for x in ${COMP_WORDS[@]} ; do
703 + [[ ${x} == -* ]] || continue
704 + [[ ${x} == *f* ]] && file=1
705 + [[ ${x} == *a* ]] && all=1
706 + done
707 +
708 + if [[ ${file} -eq 1 ]] ; then
709 + COMPREPLY=($(compgen -f -- ${cur}))
710 + elif [[ ${all} -eq 1 ]] ; then
711 + COMPREPLY=()
712 + else
713 + _pkgname -I ${cur}
714 + fi
715 + ;;
716 + esac
717 +} &&
718 +complete -o filenames -F _epm epm
719 +
720 +# vim: ft=sh:et:ts=4:sw=4:tw=80
721
722 diff --git a/completions/equery b/completions/equery
723 new file mode 100644
724 index 0000000..a8aa829
725 --- /dev/null
726 +++ b/completions/equery
727 @@ -0,0 +1,280 @@
728 +# Gentoo Linux Bash Shell Command Completion
729 +#
730 +# Copyright 1999-2013 Gentoo Foundation
731 +# Distributed under the terms of the GNU General Public License, v2 or later
732 +
733 +source "@helpersdir@/gentoo-common.sh"
734 +
735 +#
736 +# Bash completion for the Gentoo 'equery' command
737 +#
738 +_equery()
739 +{
740 + local cur prev mode portdir i j
741 + portdir=$(_portdir)
742 + mode="GLOBAL"
743 + COMPREPLY=()
744 + cur="${COMP_WORDS[COMP_CWORD]}"
745 + prev="${COMP_WORDS[COMP_CWORD-1]}"
746 + # Find out what we're currently doing here.
747 + j=0
748 + for i in "${COMP_WORDS[@]}"; do
749 + if [[ $j -lt $COMP_CWORD ]]; then
750 + j=$((j + 1))
751 + case $i in
752 + @(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))
753 + mode=$i
754 + ;;
755 + esac
756 + fi
757 + done
758 + # Now get to work.
759 + case $mode in
760 + GLOBAL)
761 + # Complete commands and global options.
762 + case $cur in
763 + -*)
764 + COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
765 + ;;
766 + *)
767 + COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
768 + ;;
769 + esac
770 + ;;
771 + c?(hanges))
772 + # Complete package name only if it is not yet supplied.
773 + if [[ ${prev} == ${mode} ]]; then
774 + case $cur in
775 + -*)
776 + COMPREPLY=($(compgen -W "-h --help" -- $cur))
777 + ;;
778 + *)
779 + _pkgname -A $cur
780 + ;;
781 + esac
782 + else
783 + case $cur in
784 + *)
785 + COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
786 + ;;
787 + esac
788 + fi
789 + ;;
790 + f?(iles))
791 + # Only complete if the previous entry on the command line is not
792 + # a package name.
793 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
794 + # --filter=<list>: completion of the files types list
795 + if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
796 + COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
797 + dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
798 + return 0
799 + fi
800 + case $cur in
801 + --f*)
802 + # don't handle --filter= with others to avoid space after the "="
803 + COMPREPLY=($(compgen -P "--filter=" \
804 + -W "dir obj sym dev fifo path conf cmd doc man info"))
805 + ;;
806 + -*)
807 + COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
808 + --type --tree -f --filter=" -- $cur))
809 + ;;
810 + *)
811 + # Only installed packages can have their files listed.
812 + _pkgname -I $cur
813 + ;;
814 + esac
815 + fi
816 + ;;
817 + a|has)
818 + COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
819 + --overlay-tree -p --portage-tree -F --format" -- $cur))
820 + ;;
821 + y|keywords)
822 + # Only complete if the previous entry on the command line is not
823 + # a package name.
824 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
825 + case "${cur}" in
826 + -*)
827 + COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
828 + --align -T --top-position -B --bold -C --color -O --overlays
829 + -P --prefix -S --ignore-slot" -- $cur))
830 + ;;
831 + *)
832 + _pkgname -A $cur
833 + ;;
834 + esac
835 + fi
836 + ;;
837 + l?(ist))
838 + # Only complete if the previous entry on the command line is not
839 + # a package name.
840 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
841 + case "${cur}" in
842 + -*)
843 + COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
844 + --binpkgs-missing -f --full-regex -m --mask-reason -I
845 + --exclude-installed -o --overlay-tree -p --portage-tree -F
846 + --format" -- $cur))
847 + ;;
848 + *)
849 + if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
850 + _pkgname -A $cur
851 + else
852 + _pkgname -I $cur
853 + fi
854 + ;;
855 + esac
856 + fi
857 + ;;
858 + b?(elongs))
859 + # Only complete if the previous entry on the command line is not
860 + # a file name.
861 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
862 + case $cur in
863 + -*)
864 + COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
865 + --early-out -n --name-only" -- $cur))
866 + ;;
867 + *)
868 + COMPREPLY=($(compgen -f -- $cur) \
869 + $(compgen -d -S '/' -- $cur))
870 + ;;
871 + esac
872 + fi
873 + ;;
874 + u?(ses))
875 + # Only complete if the previous entry on the command line is not
876 + # a package name.
877 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
878 + case $cur in
879 + -*)
880 + COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
881 + ;;
882 + *)
883 + # Complete on all package names.
884 + _pkgname -A $cur
885 + ;;
886 + esac
887 + fi
888 + ;;
889 + w?(hich))
890 + # Only complete if the previous entry on the command line is not
891 + # a package name.
892 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
893 + case $cur in
894 + -*)
895 + COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
896 + ;;
897 + *)
898 + # Complete on all package names.
899 + _pkgname -A $cur
900 + ;;
901 + esac
902 + fi
903 + ;;
904 + g|depgraph)
905 + # Only complete if the previous entry on the command line is not
906 + # a package name.
907 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
908 + case $cur in
909 + -*)
910 + COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
911 + --no-useflags -l --linear --depth" -- $cur))
912 + ;;
913 + *)
914 + # Complete on all package names.
915 + _pkgname -A $cur
916 + ;;
917 + esac
918 + fi
919 + ;;
920 + d?(epends))
921 + # Only complete if the previous entry on the command line is not
922 + # a package name.
923 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
924 + case $cur in
925 + -*)
926 + COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
927 + --indirect --depth" -- $cur))
928 + ;;
929 + *)
930 + case $prev in
931 + -a|--all-packages)
932 + # Complete on all package names.
933 + _pkgname -A $cur
934 + ;;
935 + *)
936 + # Complete on installed package names.
937 + _pkgname -I $cur
938 + ;;
939 + esac
940 + ;;
941 + esac
942 + fi
943 + ;;
944 + m?(eta))
945 + # Only complete if the previous entry on the command line is not
946 + # a package name.
947 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
948 + _equery_meta $cur
949 + fi
950 + ;;
951 + k|check)
952 + # Only complete if the previous entry on the command line is not
953 + # a package name.
954 + if [[ ${prev} == ${mode} ]]; then
955 + case $cur in
956 + -*)
957 + COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
958 + --full-regex -o --only-failures" -- ${cur}))
959 + ;;
960 + *)
961 + # Only installed packages can have their integrity verified.
962 + _pkgname -I $cur
963 + ;;
964 + esac
965 + fi
966 + ;;
967 + s?(ize))
968 + # Only complete if the previous entry on the command line is not
969 + # a package name.
970 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
971 + case $cur in
972 + -*)
973 + COMPREPLY=($(compgen -W "-h --help -b --bytes -f
974 + --full-regex" -- $cur))
975 + ;;
976 + *)
977 + # Only installed packages can have their size calculated.
978 + _pkgname -I $cur
979 + ;;
980 + esac
981 + fi
982 + ;;
983 + h?(asuse))
984 + # Only complete if the previous entry on the command line is not
985 + # a package name.
986 + if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
987 + case $cur in
988 + -*)
989 + COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
990 + ;;
991 + *)
992 + local glob loc
993 + [[ -f ${portdir}/profiles/use.desc ]] || return 0
994 + [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
995 + glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
996 + loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
997 + COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
998 + ;;
999 + esac
1000 + fi
1001 + ;;
1002 + esac
1003 + return 0
1004 +} &&
1005 +complete -F _equery equery
1006 +
1007 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1008
1009 diff --git a/completions/euse b/completions/euse
1010 new file mode 100644
1011 index 0000000..e7bed0a
1012 --- /dev/null
1013 +++ b/completions/euse
1014 @@ -0,0 +1,60 @@
1015 +# Gentoo Linux Bash Shell Command Completion
1016 +#
1017 +# Copyright 1999-2013 Gentoo Foundation
1018 +# Distributed under the terms of the GNU General Public License, v2 or later
1019 +
1020 +source "@helpersdir@/gentoo-common.sh"
1021 +
1022 +_euse() {
1023 + local cur prev opts sopts use portdir
1024 + COMPREPLY=()
1025 + cur="${COMP_WORDS[COMP_CWORD]}"
1026 + prev="${COMP_WORDS[COMP_CWORD-1]}"
1027 + opts="-h --help -v --version -i --info -I --info-installed -a --active
1028 + -E --enable -D --disable -P --prune"
1029 + sopts="-g --global -l --local"
1030 +
1031 + if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
1032 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1033 + return 0
1034 + fi
1035 +
1036 + case "${prev}" in
1037 + -h|--help|-v|--version)
1038 + COMPREPLY=()
1039 + ;;
1040 + -a|--active)
1041 + COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
1042 + ;;
1043 + -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
1044 + portdir=$(_portdir)
1045 + use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
1046 + $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
1047 + COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
1048 + ;;
1049 + *)
1050 + local l=0 g=0
1051 +
1052 + if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
1053 + l=1
1054 + elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
1055 + g=1
1056 + fi
1057 +
1058 + if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
1059 + then
1060 + portdir=$(_portdir)
1061 +
1062 + if [[ ${l} -eq 1 ]] ; then
1063 + use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
1064 + elif [[ ${g} -eq 1 ]] ; then
1065 + use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
1066 + fi
1067 +
1068 + COMPREPLY=($(compgen -W "${use}" -- ${cur}))
1069 + fi
1070 + esac
1071 +} &&
1072 +complete -F _euse euse
1073 +
1074 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1075
1076 diff --git a/completions/gcc-config b/completions/gcc-config
1077 new file mode 100644
1078 index 0000000..80e95c3
1079 --- /dev/null
1080 +++ b/completions/gcc-config
1081 @@ -0,0 +1,45 @@
1082 +# Gentoo Linux Bash Shell Command Completion
1083 +#
1084 +# Copyright 1999-2013 Gentoo Foundation
1085 +# Distributed under the terms of the GNU General Public License, v2 or later
1086 +
1087 +#
1088 +# gcc-config completion command
1089 +#
1090 +_gcc_config() {
1091 + local cur prev opts
1092 + COMPREPLY=()
1093 + cur="${COMP_WORDS[COMP_CWORD]}"
1094 + prev="${COMP_WORDS[COMP_CWORD-1]}"
1095 + opts="-O --use-old \
1096 + -P --use-portage-chost \
1097 + -c --get-current-profile \
1098 + -l --list-profiles \
1099 + -E --print-environ \
1100 + -B --get-bin-path \
1101 + -L --get-lib-path \
1102 + -X --get-stdcxx-incdir"
1103 +
1104 + if [[ "${cur}" == -* ]] ; then
1105 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
1106 + return 0
1107 + elif [[ ${COMP_CWORD} -eq 1 ]] ; then
1108 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
1109 + $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
1110 + -- ${cur}) )
1111 + return 0
1112 + fi
1113 +
1114 + case "${prev}" in
1115 + -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
1116 + COMPREPLY=()
1117 + ;;
1118 + *)
1119 + COMPREPLY=( $(compgen -W "\
1120 + $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
1121 + ;;
1122 + esac
1123 +} &&
1124 +complete -F _gcc_config gcc-config
1125 +
1126 +# vim: ft=sh:et:ts=4:sw=4:tw=80
1127
1128 diff --git a/completions/gentoo b/completions/gentoo
1129 deleted file mode 100644
1130 index 30a1eb1..0000000
1131 --- a/completions/gentoo
1132 +++ /dev/null
1133 @@ -1,1652 +0,0 @@
1134 -# Gentoo Linux Bash Shell Command Completion
1135 -#
1136 -# Copyright 1999-2013 Gentoo Foundation
1137 -# Distributed under the terms of the GNU General Public License, v2 or later
1138 -
1139 -source "@helpersdir@/gentoo-common.sh"
1140 -
1141 -#
1142 -# emerge completion command
1143 -#
1144 -_emerge()
1145 -{
1146 - local c cur prev curword numwords opts cond prepend
1147 - local words stophere i x
1148 - local action actionpos sysactions pkgpos
1149 - local portdir=$(_portdir -o)
1150 - COMPREPLY=()
1151 - cur="${COMP_WORDS[COMP_CWORD]}"
1152 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1153 - numwords=${#COMP_WORDS[*]}
1154 - curword=${COMP_CWORD}
1155 - opts=''
1156 -
1157 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
1158 - COMPREPLY=($(compgen -f -- ${cur}))
1159 - return 0
1160 - fi
1161 -
1162 - # find action
1163 - for x in ${COMP_LINE} ; do
1164 - if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
1165 - [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
1166 - then
1167 - action=${x}
1168 - break
1169 - fi
1170 - done
1171 -
1172 - if [[ -n ${action} ]]; then
1173 - for ((i = 0; i < ${numwords}; i++ )); do
1174 - if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
1175 - actionpos=${i}
1176 - pkgpos=$((actionpos + 1))
1177 - break
1178 - fi
1179 - done
1180 -
1181 - if [[ ${action} == -* && ${action} != --* ]] ; then
1182 - case "${action}" in
1183 - -*C*) action='--unmerge' ;;
1184 - -*P*) action='--prune' ;;
1185 - -*c*) action='--clean' ;;
1186 - -*s*) action='--search' ;;
1187 - esac
1188 - fi
1189 - else
1190 - for ((i = 1; i < ${numwords}; i++ )); do
1191 - if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
1192 - pkgpos=${i}
1193 - break
1194 - fi
1195 - done
1196 - [[ -z ${pkgpos} ]] && pkgpos=${numwords}
1197 - fi
1198 -
1199 - # Handle special cases.
1200 - if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
1201 - [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
1202 - then
1203 - unset COMPREPLY
1204 - return 0
1205 - elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
1206 - unset COMPREPLY
1207 - [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
1208 - return 0
1209 - fi
1210 -
1211 - # Complete on options.
1212 - if [[ ${cur} == -* ]]; then
1213 - # If a resume option was specified, it needs special handling.
1214 - if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
1215 - if [[ ${cur} == --* ]]; then
1216 - opts="--ask --pretend --resume --skipfirst"
1217 - elif [[ ${cur} == -* ]]; then
1218 - [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
1219 - fi
1220 - elif [[ ${cur} == --* ]]; then
1221 - # Complete on long options.
1222 - opts="--alphabetical --ask \
1223 - --buildpkg --buildpkgonly \
1224 - --changelog --clean --color=y --color=n --columns --complete-graph --config \
1225 - --debug --deep --depclean \
1226 - --emptytree \
1227 - --fetch-all-uri --fetchonly \
1228 - --getbinpkg --getbinpkgonly \
1229 - --ignore-default-opts --info \
1230 - --jobs= \
1231 - --keep-going \
1232 - --metadata \
1233 - --newuse --noconfmem --nodeps --noreplace --nospinner \
1234 - --oneshot --onlydeps \
1235 - --pretend --prune \
1236 - --quiet \
1237 - --reinstall=changed-use --regen \
1238 - --search \
1239 - --sync \
1240 - --tree \
1241 - --unmerge --update --upgradeonly --usepkg --usepkgonly \
1242 - --verbose \
1243 - --with-bdeps=y --with-bdeps=n"
1244 - if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
1245 - opts="${opts} --help --resume --searchdesc --version"
1246 - fi
1247 - elif [[ ${cur} == -* ]]; then
1248 - # Complete on short options.
1249 - opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
1250 - if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
1251 - opts="${opts} -h -S -V"
1252 - fi
1253 - if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
1254 - opts="${opts} -C -P -c -s"
1255 - fi
1256 - fi
1257 -
1258 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1259 -
1260 - # NOTE: This slows things down!
1261 - # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
1262 - # This removes any options from the list of completions that have
1263 - # already been specified on the command line.
1264 - COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
1265 - (while read -d ' ' i; do
1266 - [[ -z ${i} ]] && continue
1267 - # flatten array with spaces on either side,
1268 - # otherwise we cannot grep on word boundaries of
1269 - # first and last word
1270 - COMPREPLY=" ${COMPREPLY[@]} "
1271 - # remove word from list of completions
1272 - COMPREPLY=(${COMPREPLY/ ${i%% *} / })
1273 - done
1274 - echo ${COMPREPLY[@]})))
1275 -
1276 - return 0
1277 - fi # options
1278 -
1279 - # Stop completion if a special case is encountered.
1280 - if [[ ${action} =~ (system|world) ]] || \
1281 - [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
1282 - then
1283 - unset COMPREPLY
1284 - return 0
1285 - fi
1286 -
1287 - # Complete on installed packages when unmerging.
1288 - if [[ "${action}" == '--unmerge' ]]; then
1289 - if [[ -n "${cur}" ]] ; then
1290 - if [[ "${cur}" == */* ]]; then
1291 - words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
1292 - else
1293 - words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
1294 -
1295 - local n=0
1296 - for i in ${words} ; do
1297 - [[ ${i} == ${cur}* ]] && n=$((n+1))
1298 - done
1299 -
1300 - if [[ ${n} -eq 1 ]] ; then
1301 - words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
1302 - fi
1303 - fi
1304 - COMPREPLY=($(for i in ${words} ; do \
1305 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
1306 - done))
1307 - else
1308 - COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
1309 - fi
1310 -
1311 - [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
1312 - return 0
1313 - fi
1314 -
1315 - # Check for conditional.
1316 - cond="${cur%%[A-Za-z0-9]*}"
1317 - cur="${cur:${#cond}}"
1318 - if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
1319 - prepend="-P ${cond:1}"
1320 - c="${cond:1}"
1321 - else
1322 - c="${cond}"
1323 - fi
1324 -
1325 - # Handle cases where a conditional is specified.
1326 - if [[ -n "${cond}" ]]; then
1327 - if [[ -n "${cur}" ]]; then
1328 - if [[ ${cur} == */* ]]; then
1329 - if [[ ${cur} == *-[0-9]* ]] ; then
1330 - words="$(\
1331 - for pd in ${portdir} ; do \
1332 - builtin cd ${pd} ; \
1333 - local cat="${cur%/*}" ; \
1334 - local pkg="$(echo ${cur%-[0-9]*})" ; \
1335 - pkg="${pkg##*/}" ; \
1336 - for x in ${cat}/${pkg}/*.ebuild ; do \
1337 - [[ -f ${x} ]] || continue ; \
1338 - x="${x/${pkg}\/}" ; \
1339 - echo "${x%*.ebuild}" ; \
1340 - done ; \
1341 - done)"
1342 - else
1343 - words="$(\
1344 - for pd in ${portdir} ; do \
1345 - builtin cd ${pd}; \
1346 - compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
1347 - done)"
1348 - fi
1349 -
1350 - local w
1351 - for x in $words ; do
1352 - w="${x}\n${w}"
1353 - done
1354 -
1355 - words=$(echo -ne ${w} | sort | uniq)
1356 - COMPREPLY=( ${words} )
1357 -
1358 - # Complete on the specific versions (if appropriate).
1359 - # TODO - see if we can use _pkgname
1360 - if [[ ${#COMPREPLY[@]} -le 1 ]]; then
1361 - COMPREPLY=($(
1362 - for pd in ${portdir}; do
1363 - if [[ -d ${pd}/metadata/md5-cache ]]; then
1364 - builtin cd ${pd}/metadata/md5-cache
1365 - compgen ${prepend} -G "${cur}*" -- "${cur}"
1366 - elif [[ -d ${pd}/metadata/cache ]]; then
1367 - builtin cd ${pd}/metadata/cache
1368 - compgen ${prepend} -G "${cur}*" -- "${cur}"
1369 - else
1370 - builtin cd ${pd}
1371 - local cat="${cur%/*}"
1372 - local pkg="$(echo ${cur%-[0-9]*}*)"
1373 - pkg="${pkg##*/}"
1374 - for x in ${cat}/${pkg}/*.ebuild; do
1375 - [[ -f "${x}" ]] || continue
1376 - x="${x/${pkg}\/}"
1377 - if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
1378 - echo "${c}${x%*.ebuild}"
1379 - else
1380 - echo "${x%*.ebuild}"
1381 - fi
1382 - done
1383 - fi
1384 - done
1385 - ))
1386 - else
1387 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
1388 - fi
1389 - else
1390 - words="$(\
1391 - for pd in ${portdir} ; do \
1392 - builtin cd ${pd} ; \
1393 - compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
1394 - done)"
1395 -
1396 - local w
1397 - for x in words ; do
1398 - w="${x}\n${w}"
1399 - done
1400 -
1401 - COMPREPLY=($(echo -e ${w} | uniq))
1402 - [[ ${#COMPREPLY[@]} = 1 ]] && \
1403 - COMPREPLY=($(\
1404 - for pd in ${portdir} ; do \
1405 - builtin cd ${pd} ; \
1406 - compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
1407 - done))
1408 - fi
1409 - else
1410 - words="$(\
1411 - for pd in ${portdir} ; do \
1412 - builtin cd ${pd}; \
1413 - compgen -G "*-*"; \
1414 - done)"
1415 - COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
1416 - fi
1417 -
1418 - # If all else fails, try to complete on package names without the
1419 - # category being specified.
1420 - if [[ -z "${COMPREPLY}" ]]; then
1421 - words="$(\
1422 - for pd in ${portdir} ; do \
1423 - builtin cd ${pd}; \
1424 - for i in *-*/${cur}*; do \
1425 - [[ -d $i ]] && echo ${i##*/}; \
1426 - done ; \
1427 - done)"
1428 -
1429 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
1430 -
1431 - if [[ ${#COMPREPLY[@]} -le 1 ]]; then
1432 - # Now complete on the specific versions.
1433 - words="$(
1434 - for pd in ${portdir}; do
1435 - if [[ -d ${pd}/metadata/md5-cache ]]; then
1436 - builtin cd ${pd}/metadata/md5-cache
1437 - for i in */${cur}*; do
1438 - [[ -f $i ]] && echo ${i##*/}
1439 - done
1440 - elif [[ -d ${pd}/metadata/cache ]]; then
1441 - builtin cd ${pd}/metadata/cache
1442 - for i in */${cur}*; do
1443 - [[ -f $i ]] && echo ${i##*/}
1444 - done
1445 - fi
1446 - done
1447 - )"
1448 - COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
1449 - fi
1450 - fi
1451 - return 0
1452 - fi
1453 -
1454 - # Complete on packages.
1455 - #
1456 - # Only allow these actions if no packages have been specified.
1457 - #
1458 - # TODO: This doesn't block these actions if no categories are
1459 - # specified. Please fix me.
1460 - #
1461 - # e.g. emerge -a gentoo-dev-sources
1462 - #
1463 - # will still allow system and world actions to be specified,
1464 - # as opposed to
1465 - #
1466 - # emerge -a sys-kernel/gentoo-dev-sources
1467 - #
1468 - if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
1469 - sysactions=$'\n'"system"$'\n'"world"
1470 - else
1471 - sysactions=''
1472 - fi
1473 -
1474 - if [[ -n "${cur}" ]] ; then
1475 - if [[ ${cur} == */* ]] ; then
1476 - words=$(\
1477 - for pd in ${portdir} ; do \
1478 - builtin cd ${pd}; \
1479 - compgen -X "*metadata.xml" -G "${cur}*" ; \
1480 - done)"${sysactions}"
1481 - else
1482 - local ww=$(\
1483 - for pd in ${portdir} ; do \
1484 - builtin cd ${pd} ; \
1485 - compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
1486 - done)"${sysactions}"
1487 - # complete on virtuals
1488 - ww="${ww} $(\
1489 - for pd in ${portdir} ; do \
1490 - if [[ -d ${pd}/profiles ]] ; then
1491 - find ${pd}/profiles -name virtuals -exec \
1492 - sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
1493 - sort -u
1494 - fi ; \
1495 - done)"
1496 -
1497 - local w
1498 - for x in ${ww} ; do w="${x}\n${w}" ; done
1499 -
1500 - words=$(echo -e ${w} | sort -u)
1501 -
1502 - local n=0
1503 - for i in ${words} ; do
1504 - [[ ${i} == ${cur}* ]] && n=$((n+1))
1505 - done
1506 -
1507 - if [[ ${n} -eq 1 ]] ; then
1508 - words=$(for pd in ${portdir} ; do \
1509 - builtin cd ${pd} ; \
1510 - compgen -G "*-*/*" ; \
1511 - done)"${sysactions}"
1512 - fi
1513 - fi
1514 - COMPREPLY=($(for i in ${words} ; do \
1515 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
1516 - done))
1517 - else
1518 - words="$(\
1519 - for pd in ${portdir} ; do \
1520 - builtin cd ${pd} ; \
1521 - compgen -S '/' -G "*-*" ; \
1522 - done)""${sysactions}"
1523 - COMPREPLY=($(compgen -W "${words}" -- ${cur}))
1524 - fi
1525 -
1526 - # If all else fails, try to complete on package names without the
1527 - # category being specified.
1528 - if [[ -z "${COMPREPLY}" ]]; then
1529 - words="$(\
1530 - for pd in ${portdir} ; do \
1531 - builtin cd ${pd}; \
1532 - for i in [a-z]*-[a-z0-9]*/${cur}*; do \
1533 - [[ -d $i ]] && echo ${i##*/}; \
1534 - done ; \
1535 - done)"
1536 - COMPREPLY=($(compgen -W "${words}" -- ${cur}))
1537 - fi
1538 -
1539 - return 0
1540 -} &&
1541 -complete -o filenames -F _emerge emerge
1542 -
1543 -#
1544 -# ebuild completion command
1545 -#
1546 -_ebuild()
1547 -{
1548 - local cur opts
1549 - COMPREPLY=()
1550 - cur="${COMP_WORDS[COMP_CWORD]}"
1551 -
1552 - opts="help setup clean fetch digest manifest unpack compile test preinst \
1553 - install postinst qmerge merge unmerge prerm postrm config package rpm \
1554 - configure prepare"
1555 -
1556 - if [[ $COMP_CWORD -eq 1 ]] ; then
1557 - COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
1558 - $(compgen -d -- ${cur}) \
1559 - $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
1560 -
1561 - elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
1562 - COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
1563 -
1564 - elif [[ $COMP_CWORD -ge 2 ]] ; then
1565 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
1566 - fi
1567 - return 0
1568 -} &&
1569 -complete -o filenames -F _ebuild ebuild
1570 -
1571 -#
1572 -# rc completion command
1573 -#
1574 -_rc()
1575 -{
1576 - local cur
1577 - COMPREPLY=()
1578 - cur="${COMP_WORDS[COMP_CWORD]}"
1579 - if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
1580 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1581 - fi
1582 - return 0
1583 -} &&
1584 -complete -F _rc rc
1585 -
1586 -#
1587 -# rc-status completion command
1588 -#
1589 -_rcstatus()
1590 -{
1591 - local cur
1592 - cur="${COMP_WORDS[COMP_CWORD]}"
1593 - if [[ $COMP_CWORD -eq 1 ]]; then
1594 - if [[ "${cur}" == --* ]]; then
1595 - COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
1596 - elif [[ "${cur}" == -* ]]; then
1597 - COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
1598 - else
1599 - COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
1600 - fi
1601 - else
1602 - unset COMPREPLY
1603 - fi
1604 - return 0
1605 -} &&
1606 -complete -F _rcstatus rc-status
1607 -
1608 -#
1609 -# rc-update completion command
1610 -#
1611 -_rcupdate()
1612 -{
1613 - local cur show
1614 - COMPREPLY=()
1615 - cur="${COMP_WORDS[COMP_CWORD]}"
1616 - if [[ $COMP_CWORD -eq 1 ]]; then
1617 - if [[ "${cur}" == -* ]]; then
1618 - COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
1619 - else
1620 - COMPREPLY=($(compgen -W 'add del show' ${cur}))
1621 - fi
1622 - else
1623 - if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
1624 - show="TRUE"
1625 - fi
1626 - if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
1627 - ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
1628 - then
1629 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1630 - elif [[ $COMP_CWORD -eq 2 ]]; then
1631 - COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
1632 - elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
1633 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
1634 - else
1635 - unset COMPREPLY
1636 - fi
1637 - fi
1638 - return 0
1639 -} &&
1640 -complete -F _rcupdate rc-update
1641 -
1642 -#
1643 -# gcc-config completion command
1644 -#
1645 -_gcc_config() {
1646 - local cur prev opts
1647 - COMPREPLY=()
1648 - cur="${COMP_WORDS[COMP_CWORD]}"
1649 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1650 - opts="-O --use-old \
1651 - -P --use-portage-chost \
1652 - -c --get-current-profile \
1653 - -l --list-profiles \
1654 - -E --print-environ \
1655 - -B --get-bin-path \
1656 - -L --get-lib-path \
1657 - -X --get-stdcxx-incdir"
1658 -
1659 - if [[ "${cur}" == -* ]] ; then
1660 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
1661 - return 0
1662 - elif [[ ${COMP_CWORD} -eq 1 ]] ; then
1663 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
1664 - $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
1665 - -- ${cur}) )
1666 - return 0
1667 - fi
1668 -
1669 - case "${prev}" in
1670 - -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
1671 - COMPREPLY=()
1672 - ;;
1673 - *)
1674 - COMPREPLY=( $(compgen -W "\
1675 - $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
1676 - ;;
1677 - esac
1678 -} &&
1679 -complete -F _gcc_config gcc-config
1680 -
1681 -#
1682 -# distcc-config completion command
1683 -#
1684 -_distccconfig()
1685 -{
1686 - local cur curword numwords opts
1687 - COMPREPLY=()
1688 - cur="${COMP_WORDS[COMP_CWORD]}"
1689 - numwords=${#COMP_WORDS[*]}
1690 - curword=${COMP_CWORD}
1691 - if [[ ${numwords} -gt 3 ]]; then
1692 - unset COMPREPLY
1693 - return 0
1694 - fi
1695 - if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
1696 - if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
1697 - opts="--get-hosts \
1698 - --get-verbose \
1699 - --get-log \
1700 - --set-hosts \
1701 - --set-verbose \
1702 - --set-log \
1703 - --add-path \
1704 - --no-path"
1705 - else
1706 - opts=""
1707 - fi
1708 - else
1709 - opts=""
1710 - fi
1711 - COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
1712 - return 0
1713 -} &&
1714 -complete -F _distccconfig distcc-config
1715 -
1716 -#
1717 -# java-config completion command
1718 -#
1719 -_javaconfig()
1720 -{
1721 - local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
1722 - local multiplepkgs pkgs execopts
1723 - COMPREPLY=()
1724 - cur="${COMP_WORDS[COMP_CWORD]}"
1725 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1726 - numwords=${#COMP_WORDS[*]}
1727 - curword=${COMP_CWORD}
1728 - opts=""
1729 - args=""
1730 - pkgs=""
1731 - sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
1732 - vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
1733 - grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
1734 - multiplepkgs=""
1735 - execopts="HtmlConverter JavaPluginControlPanel \
1736 - appletviewer awt_robot \
1737 - extcheck \
1738 - idlj \
1739 - j2sdk-config jar jarsigner \
1740 - java java-rmi.cgi java_vm javac javadoc javah javap jdb \
1741 - keytool kinit klist ktab \
1742 - native2ascii \
1743 - oldjava oldjavac oldjdb orbd \
1744 - policytool \
1745 - realpath rmic rmid rmiregistry \
1746 - serialver servertool \
1747 - tnameserv"
1748 - if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
1749 - case "${cur}" in
1750 - --java)
1751 - opts="--java --javac --java-version"
1752 - ;;
1753 - --j@(a@(r|va@(c|-version))|@(dk|re)-home))
1754 - opts=""
1755 - ;;
1756 - --list-available-@(packages|vms))
1757 - opts=""
1758 - ;;
1759 - --@(exec|set-@(user|system)-@(classpath|vm)))
1760 - opts="${cur}="
1761 - ;;
1762 - --set-@(user|system)-@(classpath|vm)=)
1763 - if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
1764 - flag="--list-available-vms"
1765 - args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
1766 - else
1767 - flag="--list-available-packages"
1768 - args=$(java-config --nocolor "${flag}" | ${sedcmd})
1769 - fi
1770 - for arg in ${args}; do
1771 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1772 - done
1773 - COMPREPLY=($(compgen $nospace -W "${opts}"))
1774 - return 0
1775 - ;;
1776 - --exec=)
1777 - COMPREPLY=($(compgen $nospace -W "${execopts}"))
1778 - return 0
1779 - ;;
1780 - *)
1781 - if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
1782 - args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
1783 - if [[ "${cur}" == "--set-system-vm="* ]]; then
1784 - spec=${cur##--set-system-vm=}
1785 - else
1786 - spec=${cur##--set-user-vm=}
1787 - fi
1788 - for arg in ${args}; do
1789 - if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1790 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1791 - fi
1792 - done
1793 - [[ "${opts}" == "${spec}" ]] && opts=""
1794 - COMPREPLY=($(compgen -W "${opts}"))
1795 - return 0
1796 - elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
1797 - args=$(java-config --nocolor --list-available-packages | ${sedcmd})
1798 - [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
1799 - if [[ "${cur}" == "--set-system-classpath="* ]]; then
1800 - spec="${cur##--set-system-classpath=}"
1801 - else
1802 - spec="${cur##--set-user-classpath=}"
1803 - fi
1804 - if [[ -n "${multiplepkgs}" ]]; then
1805 - pkgs="${spec%,*}"
1806 - spec="${spec##*,}"
1807 - fi
1808 - if [[ -n "${multiplepkgs}" ]]; then
1809 - for arg in ${args}; do
1810 - if [[ "${spec}" ]]; then
1811 - if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
1812 - && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
1813 - then
1814 - [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
1815 - fi
1816 - else
1817 - if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
1818 - [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
1819 - fi
1820 - fi
1821 - done
1822 - [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
1823 - else
1824 - for arg in ${args}; do
1825 - if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1826 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1827 - fi
1828 - done
1829 - [[ "${opts}" == "${spec}" ]] && opts=""
1830 - fi
1831 - COMPREPLY=($(compgen -W "${opts}"))
1832 - return 0
1833 - elif [[ "${cur}" == "--exec="* ]]; then
1834 - spec=${cur##--exec=}
1835 - for arg in ${execopts}; do
1836 - if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
1837 - [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
1838 - fi
1839 - done
1840 - [[ "${opts}" == "${spec}" ]] && opts=""
1841 - COMPREPLY=($(compgen -W "${opts}"))
1842 - return 0
1843 - else
1844 - opts="--classpath --clean-system-classpath --clean-user-classpath \
1845 - --exec \
1846 - --full-classpath \
1847 - --jar --java --javac --java-version --jdk-home --jre-home \
1848 - --list-available-packages --list-available-vms \
1849 - --nocolor \
1850 - --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
1851 - [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
1852 - fi
1853 - ;;
1854 - esac
1855 - elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
1856 - opts="--classpath --clean-system-classpath --clean-user-classpath \
1857 - --exec \
1858 - --full-classpath \
1859 - --jar --java --javac --java-version --jdk-home --jre-home \
1860 - --list-available-packages --list-available-vms \
1861 - --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
1862 - fi
1863 - COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
1864 - return 0
1865 -} &&
1866 -complete $nospace -F _javaconfig java-config
1867 -
1868 -#
1869 -# browser-config completion command
1870 -#
1871 -_browserconfig()
1872 -{
1873 - local cur prev
1874 - COMPREPLY=()
1875 - cur="${COMP_WORDS[COMP_CWORD]}"
1876 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1877 - if [[ ${COMP_CWORD} -eq 1 ]]; then
1878 - COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
1879 - elif [[ "${prev}" == "-b" ]]; then
1880 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
1881 - elif [[ "${prev}" == "-m" ]]; then
1882 - COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
1883 - if [[ -z "${COMPREPLY}" ]]; then
1884 - COMPREPLY=''
1885 - fi
1886 - else
1887 - unset COMPREPLY
1888 - fi
1889 - return 0
1890 -} &&
1891 -complete -F _browserconfig browser-config
1892 -
1893 -#
1894 -# Bash completion for the Gentoo 'equery' command
1895 -#
1896 -_equery()
1897 -{
1898 - local cur prev mode portdir i j
1899 - portdir=$(_portdir)
1900 - mode="GLOBAL"
1901 - COMPREPLY=()
1902 - cur="${COMP_WORDS[COMP_CWORD]}"
1903 - prev="${COMP_WORDS[COMP_CWORD-1]}"
1904 - # Find out what we're currently doing here.
1905 - j=0
1906 - for i in "${COMP_WORDS[@]}"; do
1907 - if [[ $j -lt $COMP_CWORD ]]; then
1908 - j=$((j + 1))
1909 - case $i in
1910 - @(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))
1911 - mode=$i
1912 - ;;
1913 - esac
1914 - fi
1915 - done
1916 - # Now get to work.
1917 - case $mode in
1918 - GLOBAL)
1919 - # Complete commands and global options.
1920 - case $cur in
1921 - -*)
1922 - COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
1923 - ;;
1924 - *)
1925 - COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
1926 - ;;
1927 - esac
1928 - ;;
1929 - c?(hanges))
1930 - # Complete package name only if it is not yet supplied.
1931 - if [[ ${prev} == ${mode} ]]; then
1932 - case $cur in
1933 - -*)
1934 - COMPREPLY=($(compgen -W "-h --help" -- $cur))
1935 - ;;
1936 - *)
1937 - _pkgname -A $cur
1938 - ;;
1939 - esac
1940 - else
1941 - case $cur in
1942 - *)
1943 - COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
1944 - ;;
1945 - esac
1946 - fi
1947 - ;;
1948 - f?(iles))
1949 - # Only complete if the previous entry on the command line is not
1950 - # a package name.
1951 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1952 - # --filter=<list>: completion of the files types list
1953 - if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
1954 - COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
1955 - dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
1956 - return 0
1957 - fi
1958 - case $cur in
1959 - --f*)
1960 - # don't handle --filter= with others to avoid space after the "="
1961 - COMPREPLY=($(compgen -P "--filter=" \
1962 - -W "dir obj sym dev fifo path conf cmd doc man info"))
1963 - ;;
1964 - -*)
1965 - COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
1966 - --type --tree -f --filter=" -- $cur))
1967 - ;;
1968 - *)
1969 - # Only installed packages can have their files listed.
1970 - _pkgname -I $cur
1971 - ;;
1972 - esac
1973 - fi
1974 - ;;
1975 - a|has)
1976 - COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
1977 - --overlay-tree -p --portage-tree -F --format" -- $cur))
1978 - ;;
1979 - y|keywords)
1980 - # Only complete if the previous entry on the command line is not
1981 - # a package name.
1982 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1983 - case "${cur}" in
1984 - -*)
1985 - COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
1986 - --align -T --top-position -B --bold -C --color -O --overlays
1987 - -P --prefix -S --ignore-slot" -- $cur))
1988 - ;;
1989 - *)
1990 - _pkgname -A $cur
1991 - ;;
1992 - esac
1993 - fi
1994 - ;;
1995 - l?(ist))
1996 - # Only complete if the previous entry on the command line is not
1997 - # a package name.
1998 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
1999 - case "${cur}" in
2000 - -*)
2001 - COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
2002 - --binpkgs-missing -f --full-regex -m --mask-reason -I
2003 - --exclude-installed -o --overlay-tree -p --portage-tree -F
2004 - --format" -- $cur))
2005 - ;;
2006 - *)
2007 - if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
2008 - _pkgname -A $cur
2009 - else
2010 - _pkgname -I $cur
2011 - fi
2012 - ;;
2013 - esac
2014 - fi
2015 - ;;
2016 - b?(elongs))
2017 - # Only complete if the previous entry on the command line is not
2018 - # a file name.
2019 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2020 - case $cur in
2021 - -*)
2022 - COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
2023 - --early-out -n --name-only" -- $cur))
2024 - ;;
2025 - *)
2026 - COMPREPLY=($(compgen -f -- $cur) \
2027 - $(compgen -d -S '/' -- $cur))
2028 - ;;
2029 - esac
2030 - fi
2031 - ;;
2032 - u?(ses))
2033 - # Only complete if the previous entry on the command line is not
2034 - # a package name.
2035 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2036 - case $cur in
2037 - -*)
2038 - COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
2039 - ;;
2040 - *)
2041 - # Complete on all package names.
2042 - _pkgname -A $cur
2043 - ;;
2044 - esac
2045 - fi
2046 - ;;
2047 - w?(hich))
2048 - # Only complete if the previous entry on the command line is not
2049 - # a package name.
2050 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2051 - case $cur in
2052 - -*)
2053 - COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
2054 - ;;
2055 - *)
2056 - # Complete on all package names.
2057 - _pkgname -A $cur
2058 - ;;
2059 - esac
2060 - fi
2061 - ;;
2062 - g|depgraph)
2063 - # Only complete if the previous entry on the command line is not
2064 - # a package name.
2065 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2066 - case $cur in
2067 - -*)
2068 - COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
2069 - --no-useflags -l --linear --depth" -- $cur))
2070 - ;;
2071 - *)
2072 - # Complete on all package names.
2073 - _pkgname -A $cur
2074 - ;;
2075 - esac
2076 - fi
2077 - ;;
2078 - d?(epends))
2079 - # Only complete if the previous entry on the command line is not
2080 - # a package name.
2081 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2082 - case $cur in
2083 - -*)
2084 - COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
2085 - --indirect --depth" -- $cur))
2086 - ;;
2087 - *)
2088 - case $prev in
2089 - -a|--all-packages)
2090 - # Complete on all package names.
2091 - _pkgname -A $cur
2092 - ;;
2093 - *)
2094 - # Complete on installed package names.
2095 - _pkgname -I $cur
2096 - ;;
2097 - esac
2098 - ;;
2099 - esac
2100 - fi
2101 - ;;
2102 - m?(eta))
2103 - # Only complete if the previous entry on the command line is not
2104 - # a package name.
2105 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2106 - _equery_meta $cur
2107 - fi
2108 - ;;
2109 - k|check)
2110 - # Only complete if the previous entry on the command line is not
2111 - # a package name.
2112 - if [[ ${prev} == ${mode} ]]; then
2113 - case $cur in
2114 - -*)
2115 - COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
2116 - --full-regex -o --only-failures" -- ${cur}))
2117 - ;;
2118 - *)
2119 - # Only installed packages can have their integrity verified.
2120 - _pkgname -I $cur
2121 - ;;
2122 - esac
2123 - fi
2124 - ;;
2125 - s?(ize))
2126 - # Only complete if the previous entry on the command line is not
2127 - # a package name.
2128 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2129 - case $cur in
2130 - -*)
2131 - COMPREPLY=($(compgen -W "-h --help -b --bytes -f
2132 - --full-regex" -- $cur))
2133 - ;;
2134 - *)
2135 - # Only installed packages can have their size calculated.
2136 - _pkgname -I $cur
2137 - ;;
2138 - esac
2139 - fi
2140 - ;;
2141 - h?(asuse))
2142 - # Only complete if the previous entry on the command line is not
2143 - # a package name.
2144 - if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
2145 - case $cur in
2146 - -*)
2147 - COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
2148 - ;;
2149 - *)
2150 - local glob loc
2151 - [[ -f ${portdir}/profiles/use.desc ]] || return 0
2152 - [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
2153 - glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
2154 - loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
2155 - COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
2156 - ;;
2157 - esac
2158 - fi
2159 - ;;
2160 - esac
2161 - return 0
2162 -} &&
2163 -complete -F _equery equery
2164 -
2165 -#
2166 -# epkginfo completion
2167 -#
2168 -
2169 -_epkginfo()
2170 -{
2171 - local cur prev
2172 - cur="${COMP_WORDS[COMP_CWORD]}"
2173 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2174 -
2175 - # Only complete if the previous entry on the command line is not
2176 - # a package name.
2177 - if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
2178 - _equery_meta $cur
2179 - fi
2180 -
2181 - return 0
2182 -} &&
2183 -complete -F _epkginfo epkginfo
2184 -
2185 -#
2186 -# ekeyword completion
2187 -#
2188 -
2189 -_ekeyword()
2190 -{
2191 - local cur portdir archl_s archl_u archl_r archl_m arch
2192 - COMPREPLY=()
2193 - cur="${COMP_WORDS[COMP_CWORD]}"
2194 - portdir=$(_portdir)
2195 -
2196 - [[ -f ${portdir}/profiles/arch.list ]] || return 0
2197 -
2198 - for arch in all $(< ${portdir}/profiles/arch.list) ; do
2199 - archl_m="${archl_m} -${arch}"
2200 - archl_u="${archl_u} ~${arch}"
2201 - archl_r="${archl_r} ^${arch}"
2202 - archl_s="${archl_s} ${arch}"
2203 - done
2204 -
2205 - case ${cur} in
2206 - -*)
2207 - COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
2208 - ;;
2209 - ~*)
2210 - COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
2211 - ;;
2212 - ^*)
2213 - COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
2214 - ;;
2215 - *)
2216 - COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
2217 - _filedir 'ebuild'
2218 - ;;
2219 - esac
2220 -} &&
2221 -complete -o filenames -F _ekeyword ekeyword
2222 -
2223 -#
2224 -# portageq completion
2225 -#
2226 -
2227 -_portageq() {
2228 - local cur prev opts
2229 - COMPREPLY=()
2230 - cur="${COMP_WORDS[COMP_CWORD]}"
2231 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2232 -
2233 - opts="config_protect_mask \
2234 - config_protect \
2235 - vdb_path \
2236 - gentoo_mirrors \
2237 - all_best_visible \
2238 - match \
2239 - best_visible \
2240 - mass_best_visible \
2241 - has_version \
2242 - portdir \
2243 - envvar \
2244 - mass_best_version \
2245 - best_version \
2246 - pkgdir \
2247 - portdir_overlay \
2248 - distdir"
2249 -
2250 - if [[ $COMP_CWORD -eq 1 ]] ; then
2251 - # would always be correct, but it's pretty slow...
2252 - #COMPREPLY=($(compgen -W "$(portageq | grep '^ [[:lower:]]' | \
2253 - # sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
2254 - # -- ${cur}))
2255 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2256 - fi
2257 -
2258 - case "${prev}" in
2259 - config*|vdb_path|gentoo_mirrors|*dir*)
2260 - COMPREPLY=()
2261 - ;;
2262 -
2263 - # this also isn't the fastest, but I welcome an alternative method
2264 - envvar)
2265 - COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
2266 - sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
2267 - ;;
2268 -
2269 - *v@(isible|ersion)|match)
2270 - COMPREPLY=($(compgen $nospace -W '/' -- $cur))
2271 - ;;
2272 -
2273 - # $prev is a path, so complete on category/package
2274 - */*)
2275 - local x a=0
2276 - for x in ${COMP_WORDS[@]} ; do
2277 - # This is the only one
2278 - if [[ "${x}" == "all_best_visible" ]] ; then
2279 - a=1
2280 - break
2281 - fi
2282 - done
2283 -
2284 - if [[ ${a} -eq 1 ]] ; then
2285 - COMPREPLY=()
2286 - else
2287 - # Check for conditional.
2288 -# cond="${cur%%[A-Za-z0-9]*}"
2289 -# cur="${cur:${#cond}}"
2290 -
2291 -# if [[ -n "${cond}" ]] ; then
2292 -# _pkgname -A $cur
2293 -# else
2294 - _pkgname -A $cur
2295 -# fi
2296 - fi
2297 - ;;
2298 - esac
2299 -} &&
2300 -complete -F _portageq portageq
2301 -
2302 -#
2303 -# webapp-config completion
2304 -#
2305 -
2306 -_webapp_complete_appver()
2307 -{
2308 - local x proot ibase cur="$2"
2309 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2310 - echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
2311 - echo ibase="${WA_INSTALLSBASE:-installs}")
2312 -
2313 - case "$1" in
2314 - # complete on installed
2315 - installed)
2316 - COMPREPLY=($(compgen -W "$(\
2317 - for x in ${proot}/*/*/installs ; do \
2318 - if [[ -f "${x}" ]] ; then \
2319 - local y="${x%/*}" ; \
2320 - y="${y%/*}" ; \
2321 - echo "${y##*/}" ; \
2322 - fi ; \
2323 - done)" -- ${cur}))
2324 - ;;
2325 -
2326 - # complete on uninstalled
2327 - uninstalled)
2328 - COMPREPLY=($(compgen -W "$(\
2329 - for x in ${proot}/*/* ; do \
2330 - if [[ ! -f "${x}/${ibase}" ]] ; then \
2331 - local y="${x%/*}" ; \
2332 - echo "${y##*/}" ; \
2333 - fi ; \
2334 - done)" -- ${cur}))
2335 - ;;
2336 -
2337 - # all
2338 - all)
2339 - COMPREPLY=($(compgen -W "$(\
2340 - for x in ${proot}/* ; do \
2341 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2342 - done)" -- ${cur}))
2343 - ;;
2344 -
2345 - # complete on version
2346 - *)
2347 - [[ -d "${proot}/$1" ]] || return 1
2348 - COMPREPLY=($(compgen -W "$(\
2349 - for x in ${proot}/$1/* ; do \
2350 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2351 - done)" -- ${cur}))
2352 - ;;
2353 - esac
2354 -}
2355 -
2356 -_webapp_config()
2357 -{
2358 - local cur prev actions opts hostroot
2359 - COMPREPLY=()
2360 - cur="${COMP_WORDS[COMP_CWORD]}"
2361 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2362 -
2363 - actions="-I --install -U --upgrade -C --clean --list-installs \
2364 - --list-unused-installs --show-installed --show-postinst \
2365 - --help -v --version"
2366 - opts="--bug-report --pretend -p -u --user -g --group \
2367 - -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
2368 - --virtual-files --force-virtual"
2369 -
2370 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2371 - echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
2372 -
2373 - # --bug-report, --pretend, and -p can only be used as first arg
2374 - if [[ ${COMP_CWORD} -gt 1 ]] ; then
2375 - opts="${opts/--bug-report --pretend -p}"
2376 - fi
2377 -
2378 - if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
2379 - COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
2380 - return 0
2381 - fi
2382 -
2383 - case "${prev}" in
2384 - --bug-report|-p|--pretend)
2385 - COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
2386 - ;;
2387 -
2388 - -I|--install)
2389 - _webapp_complete_appver all ${cur}
2390 - ;;
2391 -
2392 - -U|--upgrade)
2393 - _webapp_complete_appver installed ${cur}
2394 - ;;
2395 -
2396 - # only complete on -d since it is required if -C is specified
2397 - -C|--clean)
2398 - COMPREPLY=($(compgen -W "-d" -- ${cur}))
2399 - ;;
2400 -
2401 - --list-unused-installs)
2402 - _webapp_complete_appver uninstalled ${cur}
2403 - ;;
2404 -
2405 - --list-installs|--show-postinst)
2406 - _webapp_complete_appver all ${cur}
2407 - ;;
2408 -
2409 - # hrm... anyone know a better way to reliably do this?
2410 - -h|--host)
2411 - local x
2412 - COMPREPLY=($(compgen -W "$(\
2413 - for x in ${hostroot}/* ; do \
2414 - [[ -d "${x}" ]] && echo "${x##*/}" ; \
2415 - done)" -- ${cur}))
2416 - ;;
2417 -
2418 - --virtual*)
2419 - COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
2420 - -- ${cur}))
2421 - ;;
2422 -
2423 - -d|--dir)
2424 - local host x i=0
2425 - # see if --host has been specified, and if so, get the value
2426 - # that was passed to it.
2427 - for x in ${COMP_WORDS[@]} ; do
2428 - if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
2429 - host="${COMP_WORDS[((i+1))]}"
2430 - break
2431 - fi
2432 - i=$((i+1))
2433 - done
2434 -
2435 - # otherwise, use the default host
2436 - if [[ "${host}" == "" ]] ; then
2437 - eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
2438 - echo host="${VHOST_HOSTNAME:-localhost}")
2439 - fi
2440 -
2441 - COMPREPLY=($(compgen -W "$(\
2442 - for x in ${hostroot}${host}/* ; do \
2443 - [[ -d "${x}" ]] && echo "${x}" ; \
2444 - done)" -- ${cur}))
2445 - ;;
2446 - -u|--user)
2447 - COMPREPLY=($(compgen -u -- ${cur}))
2448 - ;;
2449 - -g|--group)
2450 - COMPREPLY=($(compgen -g -- ${cur}))
2451 - ;;
2452 -
2453 - # we haven't recognized it yet, so more than likely ${prev}
2454 - # is a 'app-name' ; assuming it is indeed a valid 'app-name'
2455 - # (_webapp_complete_appver does the check), complete on available
2456 - # 'app-version's
2457 - *)
2458 - _webapp_complete_appver ${prev} ${cur} || \
2459 - _webapp_complete_appver all ${cur}
2460 - ;;
2461 - esac
2462 -} &&
2463 -complete -F _webapp_config webapp-config
2464 -
2465 -_revdep_rebuild() {
2466 - local cur prev numwords opts
2467 - local words i x
2468 - local action actionpos
2469 - COMPREPLY=()
2470 - cur="${COMP_WORDS[COMP_CWORD]}"
2471 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2472 - numwords=${#COMP_WORDS[*]}
2473 -
2474 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
2475 - COMPREPLY=($(compgen -f -- ${cur}))
2476 - return 0
2477 - fi
2478 -
2479 - # find action
2480 - for ((i = 0; i < ${numwords}; i++ )); do
2481 - case ${COMP_WORDS[${i}]} in
2482 - --library|-L)
2483 - action=${COMP_WORDS[${i}]}
2484 - actionpos=${i}
2485 - ;;
2486 - --help|-h)
2487 - action=${COMP_WORDS[${i}]}
2488 - actionpos=${i}
2489 - ;;
2490 - esac
2491 - done
2492 -
2493 - if [[ ${cur} == -* ]]; then
2494 - if [[ ${cur} == --* ]]; then
2495 - opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
2496 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2497 - else
2498 - opts="-e -h -i -k -L -l -o -p -P -q -u -v"
2499 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2500 - fi
2501 - return 0
2502 - fi
2503 - if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
2504 - if [[ "${cur}" == */* ]]; then
2505 - COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
2506 - else
2507 - COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
2508 - fi
2509 - fi
2510 - return 0
2511 -} &&
2512 -complete -F _revdep_rebuild revdep-rebuild
2513 -
2514 -_splat() {
2515 - local cur prev opts
2516 - COMPREPLY=()
2517 - cur="${COMP_WORDS[COMP_CWORD]}"
2518 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2519 - opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
2520 - --list -u --count -p --package -t --sort -r --reverse"
2521 -
2522 - if [[ ${cur} == -* ]] ; then
2523 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2524 - return 0
2525 - fi
2526 -
2527 - case "${prev}" in
2528 - -f|--logfile)
2529 - COMPREPLY=($(compgen -f -- ${cur}))
2530 - ;;
2531 - *)
2532 - _pkgname -A ${cur}
2533 - COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
2534 - ;;
2535 - esac
2536 -} &&
2537 -complete -o filenames -F _splat splat
2538 -
2539 -_euse() {
2540 - local cur prev opts sopts use portdir
2541 - COMPREPLY=()
2542 - cur="${COMP_WORDS[COMP_CWORD]}"
2543 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2544 - opts="-h --help -v --version -i --info -I --info-installed -a --active
2545 - -E --enable -D --disable -P --prune"
2546 - sopts="-g --global -l --local"
2547 -
2548 - if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
2549 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2550 - return 0
2551 - fi
2552 -
2553 - case "${prev}" in
2554 - -h|--help|-v|--version)
2555 - COMPREPLY=()
2556 - ;;
2557 - -a|--active)
2558 - COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
2559 - ;;
2560 - -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
2561 - portdir=$(_portdir)
2562 - use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
2563 - $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
2564 - COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
2565 - ;;
2566 - *)
2567 - local l=0 g=0
2568 -
2569 - if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
2570 - l=1
2571 - elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
2572 - g=1
2573 - fi
2574 -
2575 - if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
2576 - then
2577 - portdir=$(_portdir)
2578 -
2579 - if [[ ${l} -eq 1 ]] ; then
2580 - use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
2581 - elif [[ ${g} -eq 1 ]] ; then
2582 - use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
2583 - fi
2584 -
2585 - COMPREPLY=($(compgen -W "${use}" -- ${cur}))
2586 - fi
2587 - esac
2588 -} &&
2589 -complete -F _euse euse
2590 -
2591 -_glsa_check() {
2592 - local cur opts
2593 - COMPREPLY=()
2594 - cur="${COMP_WORDS[COMP_CWORD]}"
2595 - opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
2596 - --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
2597 - -c --cve -m --mail"
2598 -
2599 - if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2600 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2601 - return 0
2602 - fi
2603 -
2604 - # too slow otherwise
2605 - if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
2606 - [[ $(stat ${ROOT}/tmp/gc.out | \
2607 - sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
2608 - then
2609 - glsa-check -nl 2>/dev/null | \
2610 - sed -n -e 's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
2611 - ${ROOT}/tmp/gc.out
2612 - fi
2613 -
2614 - COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
2615 -} &&
2616 -complete -F _glsa_check glsa-check
2617 -
2618 -_epm() {
2619 - local cur prev opts
2620 - COMPREPLY=()
2621 - cur="${COMP_WORDS[COMP_CWORD]}"
2622 - prev="${COMP_WORDS[COMP_CWORD]}"
2623 - opts="-q --query -V -y --verify -e --erase --help"
2624 -
2625 - if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2626 - COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2627 - return 0
2628 - fi
2629 -
2630 - case "${prev}" in
2631 - --help)
2632 - COMPREPLY=()
2633 - ;;
2634 - -q|--query)
2635 - _pkgname -I ${cur}
2636 - COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
2637 - ;;
2638 - *)
2639 - local x all=0 file=0
2640 - for x in ${COMP_WORDS[@]} ; do
2641 - [[ ${x} == -* ]] || continue
2642 - [[ ${x} == *f* ]] && file=1
2643 - [[ ${x} == *a* ]] && all=1
2644 - done
2645 -
2646 - if [[ ${file} -eq 1 ]] ; then
2647 - COMPREPLY=($(compgen -f -- ${cur}))
2648 - elif [[ ${all} -eq 1 ]] ; then
2649 - COMPREPLY=()
2650 - else
2651 - _pkgname -I ${cur}
2652 - fi
2653 - ;;
2654 - esac
2655 -} &&
2656 -complete -o filenames -F _epm epm
2657 -
2658 -_metagen() {
2659 - local cur prev opts
2660 - COMPREPLY=()
2661 - _get_comp_words_by_ref cur prev
2662 - opts="$(_parse_help ${COMP_WORDS[0]})"
2663 -
2664 - case $prev in
2665 - -h|--help|--version)
2666 - return 0
2667 - ;;
2668 - -H|-e|-n|-d|-l)
2669 - return 0
2670 - ;;
2671 - -o)
2672 - _filedir
2673 - return 0
2674 - ;;
2675 - esac
2676 -
2677 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2678 - return 0
2679 -} &&
2680 -complete -F _metagen metagen
2681 -
2682 -_rc_service() {
2683 - local cur prev numwords opts
2684 - local words i x filename
2685 - local action actionpos
2686 - COMPREPLY=()
2687 - cur="${COMP_WORDS[COMP_CWORD]}"
2688 - prev="${COMP_WORDS[COMP_CWORD-1]}"
2689 - numwords=${#COMP_WORDS[*]}
2690 -
2691 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
2692 - COMPREPLY=($(compgen -f -- ${cur}))
2693 - return 0
2694 - fi
2695 -
2696 - # find action
2697 - for x in ${COMP_LINE} ; do
2698 - if [[ ${x} =~ --(list|exists|resolve) ]] || \
2699 - [[ ${x} =~ -(l|e|r) ]]
2700 - then
2701 - action=${x}
2702 - break
2703 - fi
2704 - done
2705 - if [[ -n ${action} ]]; then
2706 - for ((i = 0; i < ${numwords}; i++ )); do
2707 - if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
2708 - actionpos=${i}
2709 - break
2710 - fi
2711 - done
2712 -
2713 - for ((i = 1; i < ${numwords}; i++ )); do
2714 - if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
2715 - break
2716 - fi
2717 - done
2718 - fi
2719 -
2720 - if [[ ${COMP_CWORD} -eq 3 ]]; then
2721 - return 1
2722 - fi
2723 -
2724 - # check if an option was typed
2725 - if [[ ${cur} == -* ]]; then
2726 - if [[ ${cur} == --* ]]; then
2727 - opts="--list --exists --resolve"
2728 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2729 - return 0
2730 - elif [[ ${cur} == -* ]]; then
2731 - opts="-l -e -r"
2732 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2733 - return 0
2734 - fi
2735 -
2736 -
2737 - # NOTE: This slows things down!
2738 - # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
2739 - # This removes any options from the list of completions that have
2740 - # already been specified on the command line.
2741 - COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
2742 - (while read -d ' ' i; do
2743 - [[ -z ${i} ]] && continue
2744 - # flatten array with spaces on either side,
2745 - # otherwise we cannot grep on word boundaries of
2746 - # first and last word
2747 - COMPREPLY=" ${COMPREPLY[@]} "
2748 - # remove word from list of completions
2749 - COMPREPLY=(${COMPREPLY/ ${i%% *} / })
2750 - done
2751 - echo ${COMPREPLY[@]})))
2752 -
2753 - return 0
2754 - # if no option typed
2755 - else
2756 - if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
2757 - words="`rc-service -l | grep ^${cur}`" # complete for init scripts
2758 - COMPREPLY=($(for i in ${words} ; do \
2759 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
2760 - done))
2761 - return 0
2762 - elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
2763 - filename=`rc-service -r ${prev}`
2764 - opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"` # Greps the functions included in the init script
2765 - if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm
2766 - opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
2767 - fi
2768 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
2769 - return 0
2770 - fi
2771 - fi
2772 - if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
2773 - [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
2774 - words="`rc-service -l | grep ^${cur}`"
2775 - COMPREPLY=($(for i in ${words} ; do \
2776 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
2777 - done))
2778 - return 0
2779 - fi
2780 -
2781 - return 0
2782 -} &&
2783 -complete -F _rc_service rc-service
2784 -
2785 -# vim: ft=sh:et:ts=4:sw=4:tw=80
2786
2787 diff --git a/completions/glsa-check b/completions/glsa-check
2788 new file mode 100644
2789 index 0000000..76f6466
2790 --- /dev/null
2791 +++ b/completions/glsa-check
2792 @@ -0,0 +1,33 @@
2793 +# Gentoo Linux Bash Shell Command Completion
2794 +#
2795 +# Copyright 1999-2013 Gentoo Foundation
2796 +# Distributed under the terms of the GNU General Public License, v2 or later
2797 +
2798 +_glsa_check() {
2799 + local cur opts
2800 + COMPREPLY=()
2801 + cur="${COMP_WORDS[COMP_CWORD]}"
2802 + opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
2803 + --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
2804 + -c --cve -m --mail"
2805 +
2806 + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2807 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
2808 + return 0
2809 + fi
2810 +
2811 + # too slow otherwise
2812 + if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
2813 + [[ $(stat ${ROOT}/tmp/gc.out | \
2814 + sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
2815 + then
2816 + glsa-check -nl 2>/dev/null | \
2817 + sed -n -e 's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
2818 + ${ROOT}/tmp/gc.out
2819 + fi
2820 +
2821 + COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
2822 +} &&
2823 +complete -F _glsa_check glsa-check
2824 +
2825 +# vim: ft=sh:et:ts=4:sw=4:tw=80
2826
2827 diff --git a/completions/java-config b/completions/java-config
2828 new file mode 100644
2829 index 0000000..42bf11e
2830 --- /dev/null
2831 +++ b/completions/java-config
2832 @@ -0,0 +1,158 @@
2833 +# Gentoo Linux Bash Shell Command Completion
2834 +#
2835 +# Copyright 1999-2013 Gentoo Foundation
2836 +# Distributed under the terms of the GNU General Public License, v2 or later
2837 +
2838 +#
2839 +# java-config completion command
2840 +#
2841 +_javaconfig()
2842 +{
2843 + local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
2844 + local multiplepkgs pkgs execopts
2845 + COMPREPLY=()
2846 + cur="${COMP_WORDS[COMP_CWORD]}"
2847 + prev="${COMP_WORDS[COMP_CWORD-1]}"
2848 + numwords=${#COMP_WORDS[*]}
2849 + curword=${COMP_CWORD}
2850 + opts=""
2851 + args=""
2852 + pkgs=""
2853 + sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
2854 + vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
2855 + grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
2856 + multiplepkgs=""
2857 + execopts="HtmlConverter JavaPluginControlPanel \
2858 + appletviewer awt_robot \
2859 + extcheck \
2860 + idlj \
2861 + j2sdk-config jar jarsigner \
2862 + java java-rmi.cgi java_vm javac javadoc javah javap jdb \
2863 + keytool kinit klist ktab \
2864 + native2ascii \
2865 + oldjava oldjavac oldjdb orbd \
2866 + policytool \
2867 + realpath rmic rmid rmiregistry \
2868 + serialver servertool \
2869 + tnameserv"
2870 + if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
2871 + case "${cur}" in
2872 + --java)
2873 + opts="--java --javac --java-version"
2874 + ;;
2875 + --j@(a@(r|va@(c|-version))|@(dk|re)-home))
2876 + opts=""
2877 + ;;
2878 + --list-available-@(packages|vms))
2879 + opts=""
2880 + ;;
2881 + --@(exec|set-@(user|system)-@(classpath|vm)))
2882 + opts="${cur}="
2883 + ;;
2884 + --set-@(user|system)-@(classpath|vm)=)
2885 + if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
2886 + flag="--list-available-vms"
2887 + args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
2888 + else
2889 + flag="--list-available-packages"
2890 + args=$(java-config --nocolor "${flag}" | ${sedcmd})
2891 + fi
2892 + for arg in ${args}; do
2893 + [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
2894 + done
2895 + COMPREPLY=($(compgen $nospace -W "${opts}"))
2896 + return 0
2897 + ;;
2898 + --exec=)
2899 + COMPREPLY=($(compgen $nospace -W "${execopts}"))
2900 + return 0
2901 + ;;
2902 + *)
2903 + if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
2904 + args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
2905 + if [[ "${cur}" == "--set-system-vm="* ]]; then
2906 + spec=${cur##--set-system-vm=}
2907 + else
2908 + spec=${cur##--set-user-vm=}
2909 + fi
2910 + for arg in ${args}; do
2911 + if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
2912 + [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
2913 + fi
2914 + done
2915 + [[ "${opts}" == "${spec}" ]] && opts=""
2916 + COMPREPLY=($(compgen -W "${opts}"))
2917 + return 0
2918 + elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
2919 + args=$(java-config --nocolor --list-available-packages | ${sedcmd})
2920 + [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
2921 + if [[ "${cur}" == "--set-system-classpath="* ]]; then
2922 + spec="${cur##--set-system-classpath=}"
2923 + else
2924 + spec="${cur##--set-user-classpath=}"
2925 + fi
2926 + if [[ -n "${multiplepkgs}" ]]; then
2927 + pkgs="${spec%,*}"
2928 + spec="${spec##*,}"
2929 + fi
2930 + if [[ -n "${multiplepkgs}" ]]; then
2931 + for arg in ${args}; do
2932 + if [[ "${spec}" ]]; then
2933 + if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
2934 + && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
2935 + then
2936 + [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
2937 + fi
2938 + else
2939 + if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
2940 + [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
2941 + fi
2942 + fi
2943 + done
2944 + [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
2945 + else
2946 + for arg in ${args}; do
2947 + if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
2948 + [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
2949 + fi
2950 + done
2951 + [[ "${opts}" == "${spec}" ]] && opts=""
2952 + fi
2953 + COMPREPLY=($(compgen -W "${opts}"))
2954 + return 0
2955 + elif [[ "${cur}" == "--exec="* ]]; then
2956 + spec=${cur##--exec=}
2957 + for arg in ${execopts}; do
2958 + if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
2959 + [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
2960 + fi
2961 + done
2962 + [[ "${opts}" == "${spec}" ]] && opts=""
2963 + COMPREPLY=($(compgen -W "${opts}"))
2964 + return 0
2965 + else
2966 + opts="--classpath --clean-system-classpath --clean-user-classpath \
2967 + --exec \
2968 + --full-classpath \
2969 + --jar --java --javac --java-version --jdk-home --jre-home \
2970 + --list-available-packages --list-available-vms \
2971 + --nocolor \
2972 + --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
2973 + [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
2974 + fi
2975 + ;;
2976 + esac
2977 + elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
2978 + opts="--classpath --clean-system-classpath --clean-user-classpath \
2979 + --exec \
2980 + --full-classpath \
2981 + --jar --java --javac --java-version --jdk-home --jre-home \
2982 + --list-available-packages --list-available-vms \
2983 + --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
2984 + fi
2985 + COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
2986 + return 0
2987 +} &&
2988 +complete $nospace -F _javaconfig java-config
2989 +
2990 +# vim: ft=sh:et:ts=4:sw=4:tw=80
2991
2992 diff --git a/completions/metagen b/completions/metagen
2993 new file mode 100644
2994 index 0000000..3ba0dc9
2995 --- /dev/null
2996 +++ b/completions/metagen
2997 @@ -0,0 +1,30 @@
2998 +# Gentoo Linux Bash Shell Command Completion
2999 +#
3000 +# Copyright 1999-2013 Gentoo Foundation
3001 +# Distributed under the terms of the GNU General Public License, v2 or later
3002 +
3003 +_metagen() {
3004 + local cur prev opts
3005 + COMPREPLY=()
3006 + _get_comp_words_by_ref cur prev
3007 + opts="$(_parse_help ${COMP_WORDS[0]})"
3008 +
3009 + case $prev in
3010 + -h|--help|--version)
3011 + return 0
3012 + ;;
3013 + -H|-e|-n|-d|-l)
3014 + return 0
3015 + ;;
3016 + -o)
3017 + _filedir
3018 + return 0
3019 + ;;
3020 + esac
3021 +
3022 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3023 + return 0
3024 +} &&
3025 +complete -F _metagen metagen
3026 +
3027 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3028
3029 diff --git a/completions/portageq b/completions/portageq
3030 new file mode 100644
3031 index 0000000..7922e59
3032 --- /dev/null
3033 +++ b/completions/portageq
3034 @@ -0,0 +1,87 @@
3035 +# Gentoo Linux Bash Shell Command Completion
3036 +#
3037 +# Copyright 1999-2013 Gentoo Foundation
3038 +# Distributed under the terms of the GNU General Public License, v2 or later
3039 +
3040 +source "@helpersdir@/gentoo-common.sh"
3041 +
3042 +#
3043 +# portageq completion
3044 +#
3045 +
3046 +_portageq() {
3047 + local cur prev opts
3048 + COMPREPLY=()
3049 + cur="${COMP_WORDS[COMP_CWORD]}"
3050 + prev="${COMP_WORDS[COMP_CWORD-1]}"
3051 +
3052 + opts="config_protect_mask \
3053 + config_protect \
3054 + vdb_path \
3055 + gentoo_mirrors \
3056 + all_best_visible \
3057 + match \
3058 + best_visible \
3059 + mass_best_visible \
3060 + has_version \
3061 + portdir \
3062 + envvar \
3063 + mass_best_version \
3064 + best_version \
3065 + pkgdir \
3066 + portdir_overlay \
3067 + distdir"
3068 +
3069 + if [[ $COMP_CWORD -eq 1 ]] ; then
3070 + # would always be correct, but it's pretty slow...
3071 + #COMPREPLY=($(compgen -W "$(portageq | grep '^ [[:lower:]]' | \
3072 + # sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
3073 + # -- ${cur}))
3074 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
3075 + fi
3076 +
3077 + case "${prev}" in
3078 + config*|vdb_path|gentoo_mirrors|*dir*)
3079 + COMPREPLY=()
3080 + ;;
3081 +
3082 + # this also isn't the fastest, but I welcome an alternative method
3083 + envvar)
3084 + COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
3085 + sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
3086 + ;;
3087 +
3088 + *v@(isible|ersion)|match)
3089 + COMPREPLY=($(compgen $nospace -W '/' -- $cur))
3090 + ;;
3091 +
3092 + # $prev is a path, so complete on category/package
3093 + */*)
3094 + local x a=0
3095 + for x in ${COMP_WORDS[@]} ; do
3096 + # This is the only one
3097 + if [[ "${x}" == "all_best_visible" ]] ; then
3098 + a=1
3099 + break
3100 + fi
3101 + done
3102 +
3103 + if [[ ${a} -eq 1 ]] ; then
3104 + COMPREPLY=()
3105 + else
3106 + # Check for conditional.
3107 +# cond="${cur%%[A-Za-z0-9]*}"
3108 +# cur="${cur:${#cond}}"
3109 +
3110 +# if [[ -n "${cond}" ]] ; then
3111 +# _pkgname -A $cur
3112 +# else
3113 + _pkgname -A $cur
3114 +# fi
3115 + fi
3116 + ;;
3117 + esac
3118 +} &&
3119 +complete -F _portageq portageq
3120 +
3121 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3122
3123 diff --git a/completions/rc b/completions/rc
3124 new file mode 100644
3125 index 0000000..7453ed4
3126 --- /dev/null
3127 +++ b/completions/rc
3128 @@ -0,0 +1,21 @@
3129 +# Gentoo Linux Bash Shell Command Completion
3130 +#
3131 +# Copyright 1999-2013 Gentoo Foundation
3132 +# Distributed under the terms of the GNU General Public License, v2 or later
3133 +
3134 +#
3135 +# rc completion command
3136 +#
3137 +_rc()
3138 +{
3139 + local cur
3140 + COMPREPLY=()
3141 + cur="${COMP_WORDS[COMP_CWORD]}"
3142 + if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
3143 + COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
3144 + fi
3145 + return 0
3146 +} &&
3147 +complete -F _rc rc
3148 +
3149 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3150
3151 diff --git a/completions/rc-service b/completions/rc-service
3152 new file mode 100644
3153 index 0000000..9ad2ce1
3154 --- /dev/null
3155 +++ b/completions/rc-service
3156 @@ -0,0 +1,111 @@
3157 +# Gentoo Linux Bash Shell Command Completion
3158 +#
3159 +# Copyright 1999-2013 Gentoo Foundation
3160 +# Distributed under the terms of the GNU General Public License, v2 or later
3161 +
3162 +source "@helpersdir@/gentoo-common.sh"
3163 +
3164 +_rc_service() {
3165 + local cur prev numwords opts
3166 + local words i x filename
3167 + local action actionpos
3168 + COMPREPLY=()
3169 + cur="${COMP_WORDS[COMP_CWORD]}"
3170 + prev="${COMP_WORDS[COMP_CWORD-1]}"
3171 + numwords=${#COMP_WORDS[*]}
3172 +
3173 + if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
3174 + COMPREPLY=($(compgen -f -- ${cur}))
3175 + return 0
3176 + fi
3177 +
3178 + # find action
3179 + for x in ${COMP_LINE} ; do
3180 + if [[ ${x} =~ --(list|exists|resolve) ]] || \
3181 + [[ ${x} =~ -(l|e|r) ]]
3182 + then
3183 + action=${x}
3184 + break
3185 + fi
3186 + done
3187 + if [[ -n ${action} ]]; then
3188 + for ((i = 0; i < ${numwords}; i++ )); do
3189 + if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
3190 + actionpos=${i}
3191 + break
3192 + fi
3193 + done
3194 +
3195 + for ((i = 1; i < ${numwords}; i++ )); do
3196 + if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
3197 + break
3198 + fi
3199 + done
3200 + fi
3201 +
3202 + if [[ ${COMP_CWORD} -eq 3 ]]; then
3203 + return 1
3204 + fi
3205 +
3206 + # check if an option was typed
3207 + if [[ ${cur} == -* ]]; then
3208 + if [[ ${cur} == --* ]]; then
3209 + opts="--list --exists --resolve"
3210 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3211 + return 0
3212 + elif [[ ${cur} == -* ]]; then
3213 + opts="-l -e -r"
3214 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3215 + return 0
3216 + fi
3217 +
3218 +
3219 + # NOTE: This slows things down!
3220 + # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
3221 + # This removes any options from the list of completions that have
3222 + # already been specified on the command line.
3223 + COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
3224 + (while read -d ' ' i; do
3225 + [[ -z ${i} ]] && continue
3226 + # flatten array with spaces on either side,
3227 + # otherwise we cannot grep on word boundaries of
3228 + # first and last word
3229 + COMPREPLY=" ${COMPREPLY[@]} "
3230 + # remove word from list of completions
3231 + COMPREPLY=(${COMPREPLY/ ${i%% *} / })
3232 + done
3233 + echo ${COMPREPLY[@]})))
3234 +
3235 + return 0
3236 + # if no option typed
3237 + else
3238 + if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
3239 + words="`rc-service -l | grep ^${cur}`" # complete for init scripts
3240 + COMPREPLY=($(for i in ${words} ; do \
3241 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
3242 + done))
3243 + return 0
3244 + elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
3245 + filename=`rc-service -r ${prev}`
3246 + opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"` # Greps the functions included in the init script
3247 + if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm
3248 + opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
3249 + fi
3250 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3251 + return 0
3252 + fi
3253 + fi
3254 + if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
3255 + [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
3256 + words="`rc-service -l | grep ^${cur}`"
3257 + COMPREPLY=($(for i in ${words} ; do \
3258 + [[ ${i} == ${cur}* ]] && echo ${i} ; \
3259 + done))
3260 + return 0
3261 + fi
3262 +
3263 + return 0
3264 +} &&
3265 +complete -F _rc_service rc-service
3266 +
3267 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3268
3269 diff --git a/completions/rc-status b/completions/rc-status
3270 new file mode 100644
3271 index 0000000..794067f
3272 --- /dev/null
3273 +++ b/completions/rc-status
3274 @@ -0,0 +1,28 @@
3275 +# Gentoo Linux Bash Shell Command Completion
3276 +#
3277 +# Copyright 1999-2013 Gentoo Foundation
3278 +# Distributed under the terms of the GNU General Public License, v2 or later
3279 +
3280 +#
3281 +# rc-status completion command
3282 +#
3283 +_rcstatus()
3284 +{
3285 + local cur
3286 + cur="${COMP_WORDS[COMP_CWORD]}"
3287 + if [[ $COMP_CWORD -eq 1 ]]; then
3288 + if [[ "${cur}" == --* ]]; then
3289 + COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
3290 + elif [[ "${cur}" == -* ]]; then
3291 + COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
3292 + else
3293 + COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
3294 + fi
3295 + else
3296 + unset COMPREPLY
3297 + fi
3298 + return 0
3299 +} &&
3300 +complete -F _rcstatus rc-status
3301 +
3302 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3303
3304 diff --git a/completions/rc-update b/completions/rc-update
3305 new file mode 100644
3306 index 0000000..ae45744
3307 --- /dev/null
3308 +++ b/completions/rc-update
3309 @@ -0,0 +1,40 @@
3310 +# Gentoo Linux Bash Shell Command Completion
3311 +#
3312 +# Copyright 1999-2013 Gentoo Foundation
3313 +# Distributed under the terms of the GNU General Public License, v2 or later
3314 +
3315 +#
3316 +# rc-update completion command
3317 +#
3318 +_rcupdate()
3319 +{
3320 + local cur show
3321 + COMPREPLY=()
3322 + cur="${COMP_WORDS[COMP_CWORD]}"
3323 + if [[ $COMP_CWORD -eq 1 ]]; then
3324 + if [[ "${cur}" == -* ]]; then
3325 + COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
3326 + else
3327 + COMPREPLY=($(compgen -W 'add del show' ${cur}))
3328 + fi
3329 + else
3330 + if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
3331 + show="TRUE"
3332 + fi
3333 + if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
3334 + ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
3335 + then
3336 + COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
3337 + elif [[ $COMP_CWORD -eq 2 ]]; then
3338 + COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
3339 + elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
3340 + COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
3341 + else
3342 + unset COMPREPLY
3343 + fi
3344 + fi
3345 + return 0
3346 +} &&
3347 +complete -F _rcupdate rc-update
3348 +
3349 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3350
3351 diff --git a/completions/revdep-rebuild b/completions/revdep-rebuild
3352 new file mode 100644
3353 index 0000000..cb0efe7
3354 --- /dev/null
3355 +++ b/completions/revdep-rebuild
3356 @@ -0,0 +1,55 @@
3357 +# Gentoo Linux Bash Shell Command Completion
3358 +#
3359 +# Copyright 1999-2013 Gentoo Foundation
3360 +# Distributed under the terms of the GNU General Public License, v2 or later
3361 +
3362 +_revdep_rebuild() {
3363 + local cur prev numwords opts
3364 + local words i x
3365 + local action actionpos
3366 + COMPREPLY=()
3367 + cur="${COMP_WORDS[COMP_CWORD]}"
3368 + prev="${COMP_WORDS[COMP_CWORD-1]}"
3369 + numwords=${#COMP_WORDS[*]}
3370 +
3371 + if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
3372 + COMPREPLY=($(compgen -f -- ${cur}))
3373 + return 0
3374 + fi
3375 +
3376 + # find action
3377 + for ((i = 0; i < ${numwords}; i++ )); do
3378 + case ${COMP_WORDS[${i}]} in
3379 + --library|-L)
3380 + action=${COMP_WORDS[${i}]}
3381 + actionpos=${i}
3382 + ;;
3383 + --help|-h)
3384 + action=${COMP_WORDS[${i}]}
3385 + actionpos=${i}
3386 + ;;
3387 + esac
3388 + done
3389 +
3390 + if [[ ${cur} == -* ]]; then
3391 + if [[ ${cur} == --* ]]; then
3392 + opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
3393 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3394 + else
3395 + opts="-e -h -i -k -L -l -o -p -P -q -u -v"
3396 + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
3397 + fi
3398 + return 0
3399 + fi
3400 + if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
3401 + if [[ "${cur}" == */* ]]; then
3402 + COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
3403 + else
3404 + COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
3405 + fi
3406 + fi
3407 + return 0
3408 +} &&
3409 +complete -F _revdep_rebuild revdep-rebuild
3410 +
3411 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3412
3413 diff --git a/completions/splat b/completions/splat
3414 new file mode 100644
3415 index 0000000..ddae6a0
3416 --- /dev/null
3417 +++ b/completions/splat
3418 @@ -0,0 +1,33 @@
3419 +# Gentoo Linux Bash Shell Command Completion
3420 +#
3421 +# Copyright 1999-2013 Gentoo Foundation
3422 +# Distributed under the terms of the GNU General Public License, v2 or later
3423 +
3424 +source "@helpersdir@/gentoo-common.sh"
3425 +
3426 +_splat() {
3427 + local cur prev opts
3428 + COMPREPLY=()
3429 + cur="${COMP_WORDS[COMP_CWORD]}"
3430 + prev="${COMP_WORDS[COMP_CWORD-1]}"
3431 + opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
3432 + --list -u --count -p --package -t --sort -r --reverse"
3433 +
3434 + if [[ ${cur} == -* ]] ; then
3435 + COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
3436 + return 0
3437 + fi
3438 +
3439 + case "${prev}" in
3440 + -f|--logfile)
3441 + COMPREPLY=($(compgen -f -- ${cur}))
3442 + ;;
3443 + *)
3444 + _pkgname -A ${cur}
3445 + COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
3446 + ;;
3447 + esac
3448 +} &&
3449 +complete -o filenames -F _splat splat
3450 +
3451 +# vim: ft=sh:et:ts=4:sw=4:tw=80
3452
3453 diff --git a/completions/webapp-config b/completions/webapp-config
3454 new file mode 100644
3455 index 0000000..01679b5
3456 --- /dev/null
3457 +++ b/completions/webapp-config
3458 @@ -0,0 +1,169 @@
3459 +# Gentoo Linux Bash Shell Command Completion
3460 +#
3461 +# Copyright 1999-2013 Gentoo Foundation
3462 +# Distributed under the terms of the GNU General Public License, v2 or later
3463 +
3464 +#
3465 +# webapp-config completion
3466 +#
3467 +
3468 +_webapp_complete_appver()
3469 +{
3470 + local x proot ibase cur="$2"
3471 + eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
3472 + echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
3473 + echo ibase="${WA_INSTALLSBASE:-installs}")
3474 +
3475 + case "$1" in
3476 + # complete on installed
3477 + installed)
3478 + COMPREPLY=($(compgen -W "$(\
3479 + for x in ${proot}/*/*/installs ; do \
3480 + if [[ -f "${x}" ]] ; then \
3481 + local y="${x%/*}" ; \
3482 + y="${y%/*}" ; \
3483 + echo "${y##*/}" ; \
3484 + fi ; \
3485 + done)" -- ${cur}))
3486 + ;;
3487 +
3488 + # complete on uninstalled
3489 + uninstalled)
3490 + COMPREPLY=($(compgen -W "$(\
3491 + for x in ${proot}/*/* ; do \
3492 + if [[ ! -f "${x}/${ibase}" ]] ; then \
3493 + local y="${x%/*}" ; \
3494 + echo "${y##*/}" ; \
3495 + fi ; \
3496 + done)" -- ${cur}))
3497 + ;;
3498 +
3499 + # all
3500 + all)
3501 + COMPREPLY=($(compgen -W "$(\
3502 + for x in ${proot}/* ; do \
3503 + [[ -d "${x}" ]] && echo "${x##*/}" ; \
3504 + done)" -- ${cur}))
3505 + ;;
3506 +
3507 + # complete on version
3508 + *)
3509 + [[ -d "${proot}/$1" ]] || return 1
3510 + COMPREPLY=($(compgen -W "$(\
3511 + for x in ${proot}/$1/* ; do \
3512 + [[ -d "${x}" ]] && echo "${x##*/}" ; \
3513 + done)" -- ${cur}))
3514 + ;;
3515 + esac
3516 +}
3517 +
3518 +_webapp_config()
3519 +{
3520 + local cur prev actions opts hostroot
3521 + COMPREPLY=()
3522 + cur="${COMP_WORDS[COMP_CWORD]}"
3523 + prev="${COMP_WORDS[COMP_CWORD-1]}"
3524 +
3525 + actions="-I --install -U --upgrade -C --clean --list-installs \
3526 + --list-unused-installs --show-installed --show-postinst \
3527 + --help -v --version"
3528 + opts="--bug-report --pretend -p -u --user -g --group \
3529 + -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
3530 + --virtual-files --force-virtual"
3531 +
3532 + eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
3533 + echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
3534 +
3535 + # --bug-report, --pretend, and -p can only be used as first arg
3536 + if [[ ${COMP_CWORD} -gt 1 ]] ; then
3537 + opts="${opts/--bug-report --pretend -p}"
3538 + fi
3539 +
3540 + if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
3541 + COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
3542 + return 0
3543 + fi
3544 +
3545 + case "${prev}" in
3546 + --bug-report|-p|--pretend)
3547 + COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
3548 + ;;
3549 +
3550 + -I|--install)
3551 + _webapp_complete_appver all ${cur}
3552 + ;;
3553 +
3554 + -U|--upgrade)
3555 + _webapp_complete_appver installed ${cur}
3556 + ;;
3557 +
3558 + # only complete on -d since it is required if -C is specified
3559 + -C|--clean)
3560 + COMPREPLY=($(compgen -W "-d" -- ${cur}))
3561 + ;;
3562 +
3563 + --list-unused-installs)
3564 + _webapp_complete_appver uninstalled ${cur}
3565 + ;;
3566 +
3567 + --list-installs|--show-postinst)
3568 + _webapp_complete_appver all ${cur}
3569 + ;;
3570 +
3571 + # hrm... anyone know a better way to reliably do this?
3572 + -h|--host)
3573 + local x
3574 + COMPREPLY=($(compgen -W "$(\
3575 + for x in ${hostroot}/* ; do \
3576 + [[ -d "${x}" ]] && echo "${x##*/}" ; \
3577 + done)" -- ${cur}))
3578 + ;;
3579 +
3580 + --virtual*)
3581 + COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
3582 + -- ${cur}))
3583 + ;;
3584 +
3585 + -d|--dir)
3586 + local host x i=0
3587 + # see if --host has been specified, and if so, get the value
3588 + # that was passed to it.
3589 + for x in ${COMP_WORDS[@]} ; do
3590 + if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
3591 + host="${COMP_WORDS[((i+1))]}"
3592 + break
3593 + fi
3594 + i=$((i+1))
3595 + done
3596 +
3597 + # otherwise, use the default host
3598 + if [[ "${host}" == "" ]] ; then
3599 + eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
3600 + echo host="${VHOST_HOSTNAME:-localhost}")
3601 + fi
3602 +
3603 + COMPREPLY=($(compgen -W "$(\
3604 + for x in ${hostroot}${host}/* ; do \
3605 + [[ -d "${x}" ]] && echo "${x}" ; \
3606 + done)" -- ${cur}))
3607 + ;;
3608 + -u|--user)
3609 + COMPREPLY=($(compgen -u -- ${cur}))
3610 + ;;
3611 + -g|--group)
3612 + COMPREPLY=($(compgen -g -- ${cur}))
3613 + ;;
3614 +
3615 + # we haven't recognized it yet, so more than likely ${prev}
3616 + # is a 'app-name' ; assuming it is indeed a valid 'app-name'
3617 + # (_webapp_complete_appver does the check), complete on available
3618 + # 'app-version's
3619 + *)
3620 + _webapp_complete_appver ${prev} ${cur} || \
3621 + _webapp_complete_appver all ${cur}
3622 + ;;
3623 + esac
3624 +} &&
3625 +complete -F _webapp_config webapp-config
3626 +
3627 +# vim: ft=sh:et:ts=4:sw=4:tw=80