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