public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
  2018-03-02 18:06 Michał Górny
@ 2014-08-31 21:19 ` Michał Górny
  0 siblings, 0 replies; 34+ messages in thread
From: Michał Górny @ 2014-08-31 21:19 UTC (permalink / raw
  To: gentoo-commits

commit:     1781d5b81021858db447d4c63f68e081e320fd00
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 31 19:18:57 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Aug 31 19:18:57 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-bashcomp.git;a=commit;h=1781d5b8

Split completions by completed command.

---
 completions/browser-config |   31 +
 completions/distcc-config  |   41 ++
 completions/ebuild         |   34 +
 completions/ekeyword       |   46 ++
 completions/emerge         |  410 +++++++++++
 completions/epkginfo       |   28 +
 completions/epm            |   48 ++
 completions/equery         |  280 ++++++++
 completions/euse           |   60 ++
 completions/gcc-config     |   45 ++
 completions/gentoo         | 1652 --------------------------------------------
 completions/glsa-check     |   33 +
 completions/java-config    |  158 +++++
 completions/metagen        |   30 +
 completions/portageq       |   87 +++
 completions/rc             |   21 +
 completions/rc-service     |  111 +++
 completions/rc-status      |   28 +
 completions/rc-update      |   40 ++
 completions/revdep-rebuild |   55 ++
 completions/splat          |   33 +
 completions/webapp-config  |  169 +++++
 22 files changed, 1788 insertions(+), 1652 deletions(-)

diff --git a/completions/browser-config b/completions/browser-config
new file mode 100644
index 0000000..158ca42
--- /dev/null
+++ b/completions/browser-config
@@ -0,0 +1,31 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# browser-config completion command
+#
+_browserconfig()
+{
+    local cur prev
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    if [[ ${COMP_CWORD} -eq 1 ]]; then
+    COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
+    elif [[ "${prev}" == "-b" ]]; then
+    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
+    elif [[ "${prev}" == "-m" ]]; then
+        COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
+    if [[ -z "${COMPREPLY}" ]]; then
+        COMPREPLY=''
+    fi
+    else
+    unset COMPREPLY
+    fi
+    return 0
+} &&
+complete -F _browserconfig browser-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/distcc-config b/completions/distcc-config
new file mode 100644
index 0000000..41c315f
--- /dev/null
+++ b/completions/distcc-config
@@ -0,0 +1,41 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# distcc-config completion command
+#
+_distccconfig()
+{
+    local cur curword numwords opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    if [[ ${numwords} -gt 3 ]]; then
+    unset COMPREPLY
+    return 0
+    fi
+    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
+    if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
+        opts="--get-hosts \
+        --get-verbose \
+        --get-log \
+        --set-hosts \
+        --set-verbose \
+        --set-log \
+        --add-path \
+        --no-path"
+    else
+        opts=""
+    fi
+    else
+    opts=""
+    fi
+    COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
+    return 0
+} &&
+complete -F _distccconfig distcc-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/ebuild b/completions/ebuild
new file mode 100644
index 0000000..cd6e17e
--- /dev/null
+++ b/completions/ebuild
@@ -0,0 +1,34 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# ebuild completion command
+#
+_ebuild()
+{
+    local cur opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+
+    opts="help setup clean fetch digest manifest unpack compile test preinst \
+        install postinst qmerge merge unmerge prerm postrm config package rpm \
+        configure prepare"
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
+            $(compgen -d -- ${cur}) \
+            $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
+
+    elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
+    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
+
+    elif [[ $COMP_CWORD -ge 2 ]] ; then
+    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+    fi
+    return 0
+} &&
+complete -o filenames -F _ebuild ebuild
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/ekeyword b/completions/ekeyword
new file mode 100644
index 0000000..3bf3006
--- /dev/null
+++ b/completions/ekeyword
@@ -0,0 +1,46 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# ekeyword completion
+#
+
+_ekeyword()
+{
+    local cur portdir archl_s archl_u archl_r archl_m arch
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    portdir=$(_portdir)
+
+    [[ -f ${portdir}/profiles/arch.list ]] || return 0
+
+    for arch in all $(< ${portdir}/profiles/arch.list) ; do
+        archl_m="${archl_m} -${arch}"
+        archl_u="${archl_u} ~${arch}"
+        archl_r="${archl_r} ^${arch}"
+        archl_s="${archl_s}  ${arch}"
+    done
+
+    case ${cur} in
+        -*)
+            COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
+            ;;
+        ~*)
+            COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
+            ;;
+        ^*)
+            COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
+            ;;
+        *)
+            COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
+            _filedir 'ebuild'
+            ;;
+        esac
+} &&
+complete -o filenames -F _ekeyword ekeyword
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/emerge b/completions/emerge
new file mode 100644
index 0000000..63c02b4
--- /dev/null
+++ b/completions/emerge
@@ -0,0 +1,410 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# emerge completion command
+#
+_emerge()
+{
+    local c cur prev curword numwords opts cond prepend
+    local words stophere i x
+    local action actionpos sysactions pkgpos
+    local portdir=$(_portdir -o)
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    opts=''
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+        COMPREPLY=($(compgen -f -- ${cur}))
+        return 0
+    fi
+
+    # find action
+    for x in ${COMP_LINE} ; do
+        if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
+            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
+        then
+            action=${x}
+            break
+        fi
+    done
+
+    if [[ -n ${action} ]]; then
+        for ((i = 0; i < ${numwords}; i++ )); do
+            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
+                actionpos=${i}
+                pkgpos=$((actionpos + 1))
+                break
+            fi
+        done
+
+        if [[ ${action} == -* && ${action} != --* ]] ; then
+            case "${action}" in
+            -*C*) action='--unmerge' ;;
+            -*P*) action='--prune' ;;
+            -*c*) action='--clean' ;;
+            -*s*) action='--search' ;;
+            esac
+        fi
+    else
+        for ((i = 1; i < ${numwords}; i++ )); do
+            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
+                pkgpos=${i}
+                break
+            fi
+        done
+        [[ -z ${pkgpos} ]] && pkgpos=${numwords}
+    fi
+
+    # Handle special cases.
+    if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
+        [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
+    then
+        unset COMPREPLY
+        return 0
+    elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
+        unset COMPREPLY
+        [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
+        return 0
+    fi
+
+    # Complete on options.
+    if [[ ${cur} == -* ]]; then
+        # If a resume option was specified, it needs special handling.
+        if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
+            if [[ ${cur} == --* ]]; then
+                opts="--ask --pretend --resume --skipfirst"
+            elif [[ ${cur} == -* ]]; then
+                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
+            fi
+        elif [[ ${cur} == --* ]]; then
+            # Complete on long options.
+            opts="--alphabetical --ask \
+                --buildpkg --buildpkgonly \
+                --changelog --clean --color=y --color=n --columns --complete-graph --config \
+                --debug --deep --depclean \
+                --emptytree \
+                --fetch-all-uri --fetchonly \
+                --getbinpkg --getbinpkgonly \
+                --ignore-default-opts --info \
+                --jobs= \
+                --keep-going \
+                --metadata \
+                --newuse --noconfmem --nodeps --noreplace --nospinner \
+                --oneshot --onlydeps \
+                --pretend --prune \
+                --quiet \
+                --reinstall=changed-use --regen \
+                --search \
+                --sync \
+                --tree \
+                --unmerge --update --upgradeonly --usepkg --usepkgonly \
+                --verbose \
+                --with-bdeps=y --with-bdeps=n"
+            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
+                opts="${opts} --help --resume --searchdesc --version"
+            fi
+        elif [[ ${cur} == -* ]]; then
+            # Complete on short options.
+            opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
+            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
+                opts="${opts} -h -S -V"
+            fi
+            if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
+                opts="${opts} -C -P -c -s"
+            fi
+        fi
+
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+
+        # NOTE: This slows things down!
+        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
+        # This removes any options from the list of completions that have
+        # already been specified on the command line.
+        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
+            (while read -d ' ' i; do
+                [[ -z ${i} ]] && continue
+                # flatten array with spaces on either side,
+                # otherwise we cannot grep on word boundaries of
+                # first and last word
+                COMPREPLY=" ${COMPREPLY[@]} "
+                # remove word from list of completions
+                COMPREPLY=(${COMPREPLY/ ${i%% *} / })
+            done
+            echo ${COMPREPLY[@]})))
+
+        return 0
+    fi # options
+
+    # Stop completion if a special case is encountered.
+    if [[ ${action} =~ (system|world) ]] || \
+        [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
+    then
+        unset COMPREPLY
+        return 0
+    fi
+
+    # Complete on installed packages when unmerging.
+    if [[ "${action}" == '--unmerge' ]]; then
+    if [[ -n "${cur}" ]] ; then
+        if [[ "${cur}" == */* ]]; then
+        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
+        else
+        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
+
+                local n=0
+                for i in ${words} ; do
+                    [[ ${i} == ${cur}* ]] && n=$((n+1))
+                done
+
+                if [[ ${n} -eq 1 ]] ; then
+                    words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
+                fi
+        fi
+            COMPREPLY=($(for i in ${words} ; do \
+                            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+                        done))
+    else
+        COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
+    fi
+
+        [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
+        return 0
+    fi
+
+    # Check for conditional.
+    cond="${cur%%[A-Za-z0-9]*}"
+    cur="${cur:${#cond}}"
+    if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
+        prepend="-P ${cond:1}"
+        c="${cond:1}"
+    else
+        c="${cond}"
+    fi
+
+    # Handle cases where a conditional is specified.
+    if [[ -n "${cond}" ]]; then
+    if [[ -n "${cur}" ]]; then
+            if [[ ${cur} == */* ]]; then
+                if [[ ${cur} == *-[0-9]* ]] ; then
+                    words="$(\
+                        for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            local cat="${cur%/*}" ; \
+                            local pkg="$(echo ${cur%-[0-9]*})" ; \
+                            pkg="${pkg##*/}" ; \
+                            for x in ${cat}/${pkg}/*.ebuild ; do \
+                                [[ -f ${x} ]] || continue ; \
+                                x="${x/${pkg}\/}" ; \
+                                echo "${x%*.ebuild}" ; \
+                            done ; \
+                        done)"
+                else
+            words="$(\
+                    for pd in ${portdir} ; do \
+                        builtin cd ${pd}; \
+                        compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
+                    done)"
+                fi
+
+                local w
+                for x in $words ; do
+                    w="${x}\n${w}"
+                done
+
+                words=$(echo -ne ${w} | sort | uniq)
+                COMPREPLY=( ${words} )
+
+                # Complete on the specific versions (if appropriate).
+                # TODO - see if we can use _pkgname
+                if [[ ${#COMPREPLY[@]} -le 1 ]]; then
+                    COMPREPLY=($(
+                        for pd in ${portdir}; do
+                            if [[ -d ${pd}/metadata/md5-cache ]]; then
+                                builtin cd ${pd}/metadata/md5-cache
+                                compgen ${prepend} -G "${cur}*" -- "${cur}"
+                            elif [[ -d ${pd}/metadata/cache ]]; then
+                                builtin cd ${pd}/metadata/cache
+                                compgen ${prepend} -G "${cur}*" -- "${cur}"
+                            else
+                                builtin cd ${pd}
+                                local cat="${cur%/*}"
+                                local pkg="$(echo ${cur%-[0-9]*}*)"
+                                pkg="${pkg##*/}"
+                                for x in ${cat}/${pkg}/*.ebuild; do
+                                    [[ -f "${x}" ]] || continue
+                                    x="${x/${pkg}\/}"
+                                    if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
+                                        echo "${c}${x%*.ebuild}"
+                                    else
+                                        echo "${x%*.ebuild}"
+                                    fi
+                                done
+                            fi
+                        done
+                    ))
+                else
+                    COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
+                fi
+            else
+                words="$(\
+                    for pd in ${portdir} ; do \
+                        builtin cd ${pd} ; \
+                        compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
+                    done)"
+
+                local w
+                for x in words ; do
+                    w="${x}\n${w}"
+                done
+
+                COMPREPLY=($(echo -e ${w} | uniq))
+                [[ ${#COMPREPLY[@]} = 1 ]] && \
+                    COMPREPLY=($(\
+                        for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
+                        done))
+            fi
+        else
+        words="$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    compgen -G "*-*"; \
+                done)"
+        COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
+    fi
+
+        # If all else fails, try to complete on package names without the
+    # category being specified.
+    if [[ -z "${COMPREPLY}" ]]; then
+        words="$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    for i in *-*/${cur}*; do \
+                        [[ -d $i ]] && echo ${i##*/}; \
+                    done ; \
+                done)"
+
+        COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
+
+        if [[ ${#COMPREPLY[@]} -le 1 ]]; then
+            # Now complete on the specific versions.
+            words="$(
+                for pd in ${portdir}; do
+                    if [[ -d ${pd}/metadata/md5-cache ]]; then
+                        builtin cd ${pd}/metadata/md5-cache
+                        for i in */${cur}*; do
+                            [[ -f $i ]] && echo ${i##*/}
+                        done
+                    elif [[ -d ${pd}/metadata/cache ]]; then
+                        builtin cd ${pd}/metadata/cache
+                        for i in */${cur}*; do
+                            [[ -f $i ]] && echo ${i##*/}
+                        done
+                    fi
+                done
+            )"
+            COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
+        fi
+    fi
+    return 0
+    fi
+
+    # Complete on packages.
+    #
+    # Only allow these actions if no packages have been specified.
+    #
+    # TODO: This doesn't block these actions if no categories are
+    #       specified. Please fix me.
+    #
+    #       e.g. emerge -a gentoo-dev-sources
+    #
+    #            will still allow system and world actions to be specified,
+    #            as opposed to
+    #
+    #            emerge -a sys-kernel/gentoo-dev-sources
+    #
+    if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
+        sysactions=$'\n'"system"$'\n'"world"
+    else
+        sysactions=''
+    fi
+
+    if [[ -n "${cur}" ]] ; then
+        if [[ ${cur} == */* ]] ; then
+            words=$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    compgen -X "*metadata.xml" -G "${cur}*" ; \
+                done)"${sysactions}"
+        else
+            local ww=$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd} ; \
+                    compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
+                done)"${sysactions}"
+            # complete on virtuals
+            ww="${ww} $(\
+                for pd in ${portdir} ; do \
+                    if [[ -d ${pd}/profiles ]] ; then
+                        find ${pd}/profiles -name virtuals -exec \
+                            sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
+                            sort -u
+                    fi ; \
+                done)"
+
+            local w
+            for x in ${ww} ; do w="${x}\n${w}" ; done
+
+            words=$(echo -e ${w} | sort -u)
+
+            local n=0
+            for i in ${words} ; do
+                [[ ${i} == ${cur}* ]] && n=$((n+1))
+            done
+
+            if [[ ${n} -eq 1 ]] ; then
+                words=$(for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            compgen -G "*-*/*" ; \
+                        done)"${sysactions}"
+            fi
+        fi
+        COMPREPLY=($(for i in ${words} ; do \
+                        [[ ${i} == ${cur}* ]] && echo ${i} ; \
+                    done))
+    else
+        words="$(\
+            for pd in ${portdir} ; do \
+                builtin cd ${pd} ; \
+                compgen -S '/' -G "*-*" ; \
+            done)""${sysactions}"
+    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+    fi
+
+    # If all else fails, try to complete on package names without the
+    # category being specified.
+    if [[ -z "${COMPREPLY}" ]]; then
+        words="$(\
+            for pd in ${portdir} ; do \
+                builtin cd ${pd}; \
+                for i in [a-z]*-[a-z0-9]*/${cur}*; do \
+                    [[ -d $i ]] && echo ${i##*/}; \
+                done ; \
+            done)"
+    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+    fi
+
+    return 0
+} &&
+complete -o filenames -F _emerge emerge
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/epkginfo b/completions/epkginfo
new file mode 100644
index 0000000..34c81f3
--- /dev/null
+++ b/completions/epkginfo
@@ -0,0 +1,28 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# epkginfo completion
+#
+
+_epkginfo()
+{
+    local cur prev
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    # Only complete if the previous entry on the command line is not
+    # a package name.
+    if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
+        _equery_meta $cur
+    fi
+
+    return 0
+} &&
+complete -F _epkginfo epkginfo
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/epm b/completions/epm
new file mode 100644
index 0000000..e8a8caa
--- /dev/null
+++ b/completions/epm
@@ -0,0 +1,48 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_epm() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD]}"
+    opts="-q --query -V -y --verify -e --erase --help"
+
+    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        --help)
+            COMPREPLY=()
+            ;;
+        -q|--query)
+            _pkgname -I ${cur}
+            COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
+            ;;
+        *)
+            local x all=0 file=0
+            for x in ${COMP_WORDS[@]} ; do
+                [[ ${x} == -* ]] || continue
+                [[ ${x} == *f* ]] && file=1
+                [[ ${x} == *a* ]] && all=1
+            done
+
+            if [[ ${file} -eq 1 ]] ; then
+                COMPREPLY=($(compgen -f -- ${cur}))
+            elif [[ ${all} -eq 1 ]] ; then
+                COMPREPLY=()
+            else
+                _pkgname -I ${cur}
+            fi
+            ;;
+    esac
+} &&
+complete -o filenames -F _epm epm
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

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

diff --git a/completions/euse b/completions/euse
new file mode 100644
index 0000000..e7bed0a
--- /dev/null
+++ b/completions/euse
@@ -0,0 +1,60 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_euse() {
+    local cur prev opts sopts use portdir
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help -v --version -i --info -I --info-installed -a --active
+        -E --enable -D --disable -P --prune"
+    sopts="-g --global -l --local"
+
+    if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        -h|--help|-v|--version)
+            COMPREPLY=()
+            ;;
+        -a|--active)
+            COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
+            ;;
+        -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
+            portdir=$(_portdir)
+        use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
+        $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
+        COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
+            ;;
+        *)
+            local l=0 g=0
+
+            if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
+                l=1
+            elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
+                g=1
+            fi
+
+            if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
+            then
+                portdir=$(_portdir)
+
+                if [[ ${l} -eq 1 ]] ; then
+                    use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
+                elif [[ ${g} -eq 1 ]] ; then
+                    use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
+                fi
+
+                COMPREPLY=($(compgen -W "${use}" -- ${cur}))
+            fi
+    esac
+} &&
+complete -F _euse euse
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/gcc-config b/completions/gcc-config
new file mode 100644
index 0000000..80e95c3
--- /dev/null
+++ b/completions/gcc-config
@@ -0,0 +1,45 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# gcc-config completion command
+#
+_gcc_config() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-O --use-old \
+        -P --use-portage-chost \
+        -c --get-current-profile \
+        -l --list-profiles \
+        -E --print-environ \
+        -B --get-bin-path \
+        -L --get-lib-path \
+        -X --get-stdcxx-incdir"
+
+    if [[ "${cur}" == -* ]] ; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    elif [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
+            $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
+                -- ${cur}) )
+        return 0
+    fi
+
+    case "${prev}" in
+        -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
+            COMPREPLY=()
+            ;;
+        *)
+            COMPREPLY=( $(compgen -W "\
+                $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
+            ;;
+    esac
+} &&
+complete -F _gcc_config gcc-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/gentoo b/completions/gentoo
deleted file mode 100644
index 30a1eb1..0000000
--- a/completions/gentoo
+++ /dev/null
@@ -1,1652 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-source "@helpersdir@/gentoo-common.sh"
-
-#
-# emerge completion command
-#
-_emerge()
-{
-    local c cur prev curword numwords opts cond prepend
-    local words stophere i x
-    local action actionpos sysactions pkgpos
-    local portdir=$(_portdir -o)
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    opts=''
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-        COMPREPLY=($(compgen -f -- ${cur}))
-        return 0
-    fi
-
-    # find action
-    for x in ${COMP_LINE} ; do
-        if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
-            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
-        then
-            action=${x}
-            break
-        fi
-    done
-
-    if [[ -n ${action} ]]; then
-        for ((i = 0; i < ${numwords}; i++ )); do
-            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
-                actionpos=${i}
-                pkgpos=$((actionpos + 1))
-                break
-            fi
-        done
-
-        if [[ ${action} == -* && ${action} != --* ]] ; then
-            case "${action}" in
-            -*C*) action='--unmerge' ;;
-            -*P*) action='--prune' ;;
-            -*c*) action='--clean' ;;
-            -*s*) action='--search' ;;
-            esac
-        fi
-    else
-        for ((i = 1; i < ${numwords}; i++ )); do
-            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
-                pkgpos=${i}
-                break
-            fi
-        done
-        [[ -z ${pkgpos} ]] && pkgpos=${numwords}
-    fi
-
-    # Handle special cases.
-    if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
-        [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
-    then
-        unset COMPREPLY
-        return 0
-    elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
-        unset COMPREPLY
-        [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
-        return 0
-    fi
-
-    # Complete on options.
-    if [[ ${cur} == -* ]]; then
-        # If a resume option was specified, it needs special handling.
-        if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
-            if [[ ${cur} == --* ]]; then
-                opts="--ask --pretend --resume --skipfirst"
-            elif [[ ${cur} == -* ]]; then
-                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
-            fi
-        elif [[ ${cur} == --* ]]; then
-            # Complete on long options.
-            opts="--alphabetical --ask \
-                --buildpkg --buildpkgonly \
-                --changelog --clean --color=y --color=n --columns --complete-graph --config \
-                --debug --deep --depclean \
-                --emptytree \
-                --fetch-all-uri --fetchonly \
-                --getbinpkg --getbinpkgonly \
-                --ignore-default-opts --info \
-                --jobs= \
-                --keep-going \
-                --metadata \
-                --newuse --noconfmem --nodeps --noreplace --nospinner \
-                --oneshot --onlydeps \
-                --pretend --prune \
-                --quiet \
-                --reinstall=changed-use --regen \
-                --search \
-                --sync \
-                --tree \
-                --unmerge --update --upgradeonly --usepkg --usepkgonly \
-                --verbose \
-                --with-bdeps=y --with-bdeps=n"
-            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} --help --resume --searchdesc --version"
-            fi
-        elif [[ ${cur} == -* ]]; then
-            # Complete on short options.
-            opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
-            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} -h -S -V"
-            fi
-            if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
-                opts="${opts} -C -P -c -s"
-            fi
-        fi
-
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-
-        # NOTE: This slows things down!
-        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
-        # This removes any options from the list of completions that have
-        # already been specified on the command line.
-        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
-            (while read -d ' ' i; do
-                [[ -z ${i} ]] && continue
-                # flatten array with spaces on either side,
-                # otherwise we cannot grep on word boundaries of
-                # first and last word
-                COMPREPLY=" ${COMPREPLY[@]} "
-                # remove word from list of completions
-                COMPREPLY=(${COMPREPLY/ ${i%% *} / })
-            done
-            echo ${COMPREPLY[@]})))
-
-        return 0
-    fi # options
-
-    # Stop completion if a special case is encountered.
-    if [[ ${action} =~ (system|world) ]] || \
-        [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
-    then
-        unset COMPREPLY
-        return 0
-    fi
-
-    # Complete on installed packages when unmerging.
-    if [[ "${action}" == '--unmerge' ]]; then
-    if [[ -n "${cur}" ]] ; then
-        if [[ "${cur}" == */* ]]; then
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
-        else
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
-
-                local n=0
-                for i in ${words} ; do
-                    [[ ${i} == ${cur}* ]] && n=$((n+1))
-                done
-
-                if [[ ${n} -eq 1 ]] ; then
-                    words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
-                fi
-        fi
-            COMPREPLY=($(for i in ${words} ; do \
-                            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-                        done))
-    else
-        COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
-    fi
-
-        [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
-        return 0
-    fi
-
-    # Check for conditional.
-    cond="${cur%%[A-Za-z0-9]*}"
-    cur="${cur:${#cond}}"
-    if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
-        prepend="-P ${cond:1}"
-        c="${cond:1}"
-    else
-        c="${cond}"
-    fi
-
-    # Handle cases where a conditional is specified.
-    if [[ -n "${cond}" ]]; then
-    if [[ -n "${cur}" ]]; then
-            if [[ ${cur} == */* ]]; then
-                if [[ ${cur} == *-[0-9]* ]] ; then
-                    words="$(\
-                        for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            local cat="${cur%/*}" ; \
-                            local pkg="$(echo ${cur%-[0-9]*})" ; \
-                            pkg="${pkg##*/}" ; \
-                            for x in ${cat}/${pkg}/*.ebuild ; do \
-                                [[ -f ${x} ]] || continue ; \
-                                x="${x/${pkg}\/}" ; \
-                                echo "${x%*.ebuild}" ; \
-                            done ; \
-                        done)"
-                else
-            words="$(\
-                    for pd in ${portdir} ; do \
-                        builtin cd ${pd}; \
-                        compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
-                    done)"
-                fi
-
-                local w
-                for x in $words ; do
-                    w="${x}\n${w}"
-                done
-
-                words=$(echo -ne ${w} | sort | uniq)
-                COMPREPLY=( ${words} )
-
-                # Complete on the specific versions (if appropriate).
-                # TODO - see if we can use _pkgname
-                if [[ ${#COMPREPLY[@]} -le 1 ]]; then
-                    COMPREPLY=($(
-                        for pd in ${portdir}; do
-                            if [[ -d ${pd}/metadata/md5-cache ]]; then
-                                builtin cd ${pd}/metadata/md5-cache
-                                compgen ${prepend} -G "${cur}*" -- "${cur}"
-                            elif [[ -d ${pd}/metadata/cache ]]; then
-                                builtin cd ${pd}/metadata/cache
-                                compgen ${prepend} -G "${cur}*" -- "${cur}"
-                            else
-                                builtin cd ${pd}
-                                local cat="${cur%/*}"
-                                local pkg="$(echo ${cur%-[0-9]*}*)"
-                                pkg="${pkg##*/}"
-                                for x in ${cat}/${pkg}/*.ebuild; do
-                                    [[ -f "${x}" ]] || continue
-                                    x="${x/${pkg}\/}"
-                                    if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
-                                        echo "${c}${x%*.ebuild}"
-                                    else
-                                        echo "${x%*.ebuild}"
-                                    fi
-                                done
-                            fi
-                        done
-                    ))
-                else
-                    COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
-                fi
-            else
-                words="$(\
-                    for pd in ${portdir} ; do \
-                        builtin cd ${pd} ; \
-                        compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
-                    done)"
-
-                local w
-                for x in words ; do
-                    w="${x}\n${w}"
-                done
-
-                COMPREPLY=($(echo -e ${w} | uniq))
-                [[ ${#COMPREPLY[@]} = 1 ]] && \
-                    COMPREPLY=($(\
-                        for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
-                        done))
-            fi
-        else
-        words="$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    compgen -G "*-*"; \
-                done)"
-        COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
-    fi
-
-        # If all else fails, try to complete on package names without the
-    # category being specified.
-    if [[ -z "${COMPREPLY}" ]]; then
-        words="$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    for i in *-*/${cur}*; do \
-                        [[ -d $i ]] && echo ${i##*/}; \
-                    done ; \
-                done)"
-
-        COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
-
-        if [[ ${#COMPREPLY[@]} -le 1 ]]; then
-            # Now complete on the specific versions.
-            words="$(
-                for pd in ${portdir}; do
-                    if [[ -d ${pd}/metadata/md5-cache ]]; then
-                        builtin cd ${pd}/metadata/md5-cache
-                        for i in */${cur}*; do
-                            [[ -f $i ]] && echo ${i##*/}
-                        done
-                    elif [[ -d ${pd}/metadata/cache ]]; then
-                        builtin cd ${pd}/metadata/cache
-                        for i in */${cur}*; do
-                            [[ -f $i ]] && echo ${i##*/}
-                        done
-                    fi
-                done
-            )"
-            COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
-        fi
-    fi
-    return 0
-    fi
-
-    # Complete on packages.
-    #
-    # Only allow these actions if no packages have been specified.
-    #
-    # TODO: This doesn't block these actions if no categories are
-    #       specified. Please fix me.
-    #
-    #       e.g. emerge -a gentoo-dev-sources
-    #
-    #            will still allow system and world actions to be specified,
-    #            as opposed to
-    #
-    #            emerge -a sys-kernel/gentoo-dev-sources
-    #
-    if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
-        sysactions=$'\n'"system"$'\n'"world"
-    else
-        sysactions=''
-    fi
-
-    if [[ -n "${cur}" ]] ; then
-        if [[ ${cur} == */* ]] ; then
-            words=$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    compgen -X "*metadata.xml" -G "${cur}*" ; \
-                done)"${sysactions}"
-        else
-            local ww=$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd} ; \
-                    compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
-                done)"${sysactions}"
-            # complete on virtuals
-            ww="${ww} $(\
-                for pd in ${portdir} ; do \
-                    if [[ -d ${pd}/profiles ]] ; then
-                        find ${pd}/profiles -name virtuals -exec \
-                            sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
-                            sort -u
-                    fi ; \
-                done)"
-
-            local w
-            for x in ${ww} ; do w="${x}\n${w}" ; done
-
-            words=$(echo -e ${w} | sort -u)
-
-            local n=0
-            for i in ${words} ; do
-                [[ ${i} == ${cur}* ]] && n=$((n+1))
-            done
-
-            if [[ ${n} -eq 1 ]] ; then
-                words=$(for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            compgen -G "*-*/*" ; \
-                        done)"${sysactions}"
-            fi
-        fi
-        COMPREPLY=($(for i in ${words} ; do \
-                        [[ ${i} == ${cur}* ]] && echo ${i} ; \
-                    done))
-    else
-        words="$(\
-            for pd in ${portdir} ; do \
-                builtin cd ${pd} ; \
-                compgen -S '/' -G "*-*" ; \
-            done)""${sysactions}"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
-    fi
-
-    # If all else fails, try to complete on package names without the
-    # category being specified.
-    if [[ -z "${COMPREPLY}" ]]; then
-        words="$(\
-            for pd in ${portdir} ; do \
-                builtin cd ${pd}; \
-                for i in [a-z]*-[a-z0-9]*/${cur}*; do \
-                    [[ -d $i ]] && echo ${i##*/}; \
-                done ; \
-            done)"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
-    fi
-
-    return 0
-} &&
-complete -o filenames -F _emerge emerge
-
-#
-# ebuild completion command
-#
-_ebuild()
-{
-    local cur opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-
-    opts="help setup clean fetch digest manifest unpack compile test preinst \
-        install postinst qmerge merge unmerge prerm postrm config package rpm \
-        configure prepare"
-
-    if [[ $COMP_CWORD -eq 1 ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
-            $(compgen -d -- ${cur}) \
-            $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
-
-    elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
-
-    elif [[ $COMP_CWORD -ge 2 ]] ; then
-    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-    fi
-    return 0
-} &&
-complete -o filenames -F _ebuild ebuild
-
-#
-# rc completion command
-#
-_rc()
-{
-    local cur
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
-    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    fi
-    return 0
-} &&
-complete -F _rc rc
-
-#
-# rc-status completion command
-#
-_rcstatus()
-{
-    local cur
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-        if [[ "${cur}" == --* ]]; then
-        COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
-    elif [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
-    fi
-    else
-    unset COMPREPLY
-    fi
-    return 0
-} &&
-complete -F _rcstatus rc-status
-
-#
-# rc-update completion command
-#
-_rcupdate()
-{
-    local cur show
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-    if [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W 'add del show' ${cur}))
-    fi
-    else
-        if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
-        show="TRUE"
-    fi
-    if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
-            ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
-        then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    elif [[ $COMP_CWORD -eq 2 ]]; then
-        COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
-    elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    else
-        unset COMPREPLY
-    fi
-    fi
-    return 0
-} &&
-complete -F _rcupdate rc-update
-
-#
-# gcc-config completion command
-#
-_gcc_config() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-O --use-old \
-        -P --use-portage-chost \
-        -c --get-current-profile \
-        -l --list-profiles \
-        -E --print-environ \
-        -B --get-bin-path \
-        -L --get-lib-path \
-        -X --get-stdcxx-incdir"
-
-    if [[ "${cur}" == -* ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        return 0
-    elif [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
-            $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
-                -- ${cur}) )
-        return 0
-    fi
-
-    case "${prev}" in
-        -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
-            COMPREPLY=()
-            ;;
-        *)
-            COMPREPLY=( $(compgen -W "\
-                $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
-            ;;
-    esac
-} &&
-complete -F _gcc_config gcc-config
-
-#
-# distcc-config completion command
-#
-_distccconfig()
-{
-    local cur curword numwords opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    if [[ ${numwords} -gt 3 ]]; then
-    unset COMPREPLY
-    return 0
-    fi
-    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
-    if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
-        opts="--get-hosts \
-        --get-verbose \
-        --get-log \
-        --set-hosts \
-        --set-verbose \
-        --set-log \
-        --add-path \
-        --no-path"
-    else
-        opts=""
-    fi
-    else
-    opts=""
-    fi
-    COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
-    return 0
-} &&
-complete -F _distccconfig distcc-config
-
-#
-# java-config completion command
-#
-_javaconfig()
-{
-    local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
-    local multiplepkgs pkgs execopts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    opts=""
-    args=""
-    pkgs=""
-    sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
-    vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
-    grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
-    multiplepkgs=""
-    execopts="HtmlConverter JavaPluginControlPanel \
-    appletviewer awt_robot \
-    extcheck \
-    idlj \
-    j2sdk-config jar jarsigner \
-    java java-rmi.cgi java_vm javac javadoc javah javap jdb \
-    keytool kinit klist ktab \
-    native2ascii \
-    oldjava oldjavac oldjdb orbd \
-    policytool \
-    realpath rmic rmid rmiregistry \
-    serialver servertool \
-        tnameserv"
-    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
-    case "${cur}" in
-        --java)
-        opts="--java --javac --java-version"
-        ;;
-        --j@(a@(r|va@(c|-version))|@(dk|re)-home))
-        opts=""
-        ;;
-        --list-available-@(packages|vms))
-        opts=""
-        ;;
-        --@(exec|set-@(user|system)-@(classpath|vm)))
-        opts="${cur}="
-        ;;
-        --set-@(user|system)-@(classpath|vm)=)
-        if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
-            flag="--list-available-vms"
-            args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
-        else
-            flag="--list-available-packages"
-            args=$(java-config --nocolor "${flag}" | ${sedcmd})
-        fi
-        for arg in ${args}; do
-            [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-        done
-        COMPREPLY=($(compgen $nospace -W "${opts}"))
-        return 0
-        ;;
-        --exec=)
-        COMPREPLY=($(compgen $nospace -W "${execopts}"))
-        return 0
-        ;;
-        *)
-            if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
-            args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
-            if [[ "${cur}" == "--set-system-vm="* ]]; then
-            spec=${cur##--set-system-vm=}
-            else
-            spec=${cur##--set-user-vm=}
-            fi
-            for arg in ${args}; do
-            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-            fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
-            args=$(java-config --nocolor --list-available-packages | ${sedcmd})
-            [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
-            if [[ "${cur}" == "--set-system-classpath="* ]]; then
-            spec="${cur##--set-system-classpath=}"
-            else
-            spec="${cur##--set-user-classpath=}"
-            fi
-            if [[ -n "${multiplepkgs}" ]]; then
-            pkgs="${spec%,*}"
-            spec="${spec##*,}"
-            fi
-            if [[ -n "${multiplepkgs}" ]]; then
-                for arg in ${args}; do
-                if [[ "${spec}" ]]; then
-                    if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
-                        && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
-                                then
-                    [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
-                    fi
-                else
-                    if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
-                        [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
-                    fi
-                fi
-                done
-            [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
-            else
-                for arg in ${args}; do
-                if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-                fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            fi
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        elif [[ "${cur}" == "--exec="* ]]; then
-            spec=${cur##--exec=}
-            for arg in ${execopts}; do
-            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-            fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        else
-            opts="--classpath --clean-system-classpath --clean-user-classpath \
-                --exec \
-            --full-classpath \
-                --jar --java --javac --java-version --jdk-home --jre-home \
-                --list-available-packages --list-available-vms \
-            --nocolor \
-            --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
-            [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
-        fi
-            ;;
-        esac
-    elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
-    opts="--classpath --clean-system-classpath --clean-user-classpath \
-        --exec \
-        --full-classpath \
-        --jar --java --javac --java-version --jdk-home --jre-home \
-        --list-available-packages --list-available-vms \
-        --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
-    fi
-    COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
-    return 0
-} &&
-complete $nospace -F _javaconfig java-config
-
-#
-# browser-config completion command
-#
-_browserconfig()
-{
-    local cur prev
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    if [[ ${COMP_CWORD} -eq 1 ]]; then
-    COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
-    elif [[ "${prev}" == "-b" ]]; then
-    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
-    elif [[ "${prev}" == "-m" ]]; then
-        COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
-    if [[ -z "${COMPREPLY}" ]]; then
-        COMPREPLY=''
-    fi
-    else
-    unset COMPREPLY
-    fi
-    return 0
-} &&
-complete -F _browserconfig browser-config
-
-#
-# Bash completion for the Gentoo 'equery' command
-#
-_equery()
-{
-    local cur prev mode portdir i j
-    portdir=$(_portdir)
-    mode="GLOBAL"
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    # Find out what we're currently doing here.
-    j=0
-    for i in "${COMP_WORDS[@]}"; do
-        if [[ $j -lt $COMP_CWORD ]]; then
-        j=$((j + 1))
-        case $i in
-            @(belongs|ch@(anges|eck)|dep@(ends|graph)|files|has?(use)|keywords|list|meta|size|uses|which|b|c|k|d|g|f|a|h|y|l|m|s|u|w))
-            mode=$i
-            ;;
-        esac
-    fi
-    done
-    # Now get to work.
-    case $mode in
-    GLOBAL)
-        # Complete commands and global options.
-        case $cur in
-        -*)
-            COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
-            ;;
-        *)
-            COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
-            ;;
-        esac
-        ;;
-    c?(hanges))
-        # Complete package name only if it is not yet supplied.
-        if [[ ${prev} == ${mode} ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help" -- $cur))
-                ;;
-                *)
-                    _pkgname -A $cur
-                ;;
-            esac
-        else
-            case $cur in
-                *)
-                    COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
-                ;;
-            esac
-        fi
-        ;;
-    f?(iles))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            # --filter=<list>: completion of the files types list
-            if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
-                COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
-                    dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
-                return 0
-            fi
-        case $cur in
-            --f*)
-            # don't handle --filter= with others to avoid space after the "="
-            COMPREPLY=($(compgen -P "--filter=" \
-                -W "dir obj sym dev fifo path conf cmd doc man info"))
-            ;;
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
-                --type --tree -f --filter=" -- $cur))
-            ;;
-            *)
-            # Only installed packages can have their files listed.
-                _pkgname -I $cur
-            ;;
-        esac
-        fi
-        ;;
-    a|has)
-        COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
-             --overlay-tree -p --portage-tree -F --format" -- $cur))
-        ;;
-    y|keywords)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case "${cur}" in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
-                    --align -T --top-position -B --bold -C --color -O --overlays
-                    -P --prefix -S --ignore-slot" -- $cur))
-                    ;;
-                *)
-                    _pkgname -A $cur
-                    ;;
-            esac
-        fi
-        ;;
-    l?(ist))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case "${cur}" in
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
-                --binpkgs-missing -f --full-regex -m --mask-reason -I
-                --exclude-installed -o --overlay-tree -p --portage-tree -F
-                --format" -- $cur))
-            ;;
-            *)
-                if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
-                    _pkgname -A $cur
-                else
-                    _pkgname -I $cur
-                fi
-            ;;
-        esac
-        fi
-        ;;
-    b?(elongs))
-        # Only complete if the previous entry on the command line is not
-        # a file name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
-                        --early-out -n --name-only" -- $cur))
-                    ;;
-                *)
-                    COMPREPLY=($(compgen -f -- $cur) \
-                        $(compgen -d -S '/' -- $cur))
-                    ;;
-            esac
-        fi
-        ;;
-    u?(ses))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
-                ;;
-                *)
-                    # Complete on all package names.
-                    _pkgname -A $cur
-                ;;
-            esac
-        fi
-        ;;
-    w?(hich))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
-                ;;
-                *)
-                    # Complete on all package names.
-                    _pkgname -A $cur
-                ;;
-            esac
-        fi
-        ;;
-    g|depgraph)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-            -*)
-                COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
-                    --no-useflags -l --linear --depth" -- $cur))
-            ;;
-            *)
-            # Complete on all package names.
-            _pkgname -A $cur
-            ;;
-        esac
-        fi
-        ;;
-    d?(epends))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case $cur in
-            -*)
-                COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
-                    --indirect --depth" -- $cur))
-            ;;
-            *)
-            case $prev in
-                -a|--all-packages)
-                # Complete on all package names.
-                _pkgname -A $cur
-                ;;
-                *)
-                # Complete on installed package names.
-                    _pkgname -I $cur
-                ;;
-                        esac
-                        ;;
-        esac
-        fi
-        ;;
-    m?(eta))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            _equery_meta $cur
-        fi
-        ;;
-    k|check)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
-                        --full-regex -o --only-failures" -- ${cur}))
-                ;;
-                *)
-                # Only installed packages can have their integrity verified.
-                    _pkgname -I $cur
-                ;;
-            esac
-        fi
-        ;;
-    s?(ize))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case $cur in
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -b --bytes -f
-                --full-regex" -- $cur))
-            ;;
-            *)
-            # Only installed packages can have their size calculated.
-            _pkgname -I $cur
-            ;;
-        esac
-        fi
-        ;;
-        h?(asuse))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
-                ;;
-                *)
-                local glob loc
-                        [[ -f ${portdir}/profiles/use.desc ]] || return 0
-                        [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
-                glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
-                loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
-                COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
-                ;;
-            esac
-            fi
-            ;;
-    esac
-    return 0
-} &&
-complete -F _equery equery
-
-#
-# epkginfo completion
-#
-
-_epkginfo()
-{
-    local cur prev
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    # Only complete if the previous entry on the command line is not
-    # a package name.
-    if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
-        _equery_meta $cur
-    fi
-
-    return 0
-} &&
-complete -F _epkginfo epkginfo
-
-#
-# ekeyword completion
-#
-
-_ekeyword()
-{
-    local cur portdir archl_s archl_u archl_r archl_m arch
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    portdir=$(_portdir)
-
-    [[ -f ${portdir}/profiles/arch.list ]] || return 0
-
-    for arch in all $(< ${portdir}/profiles/arch.list) ; do
-        archl_m="${archl_m} -${arch}"
-        archl_u="${archl_u} ~${arch}"
-        archl_r="${archl_r} ^${arch}"
-        archl_s="${archl_s}  ${arch}"
-    done
-
-    case ${cur} in
-        -*)
-            COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
-            ;;
-        ~*)
-            COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
-            ;;
-        ^*)
-            COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
-            ;;
-        *)
-            COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
-            _filedir 'ebuild'
-            ;;
-        esac
-} &&
-complete -o filenames -F _ekeyword ekeyword
-
-#
-# portageq completion
-#
-
-_portageq() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    opts="config_protect_mask \
-      config_protect \
-      vdb_path \
-      gentoo_mirrors \
-      all_best_visible \
-      match \
-      best_visible \
-      mass_best_visible \
-      has_version \
-      portdir \
-      envvar \
-      mass_best_version \
-      best_version \
-      pkgdir \
-      portdir_overlay \
-      distdir"
-
-    if [[ $COMP_CWORD -eq 1 ]] ; then
-    # would always be correct, but it's pretty slow...
-    #COMPREPLY=($(compgen -W "$(portageq | grep '^   [[:lower:]]' | \
-    #    sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
-    #    -- ${cur}))
-    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-    fi
-
-    case "${prev}" in
-    config*|vdb_path|gentoo_mirrors|*dir*)
-        COMPREPLY=()
-        ;;
-
-    # this also isn't the fastest, but I welcome an alternative method
-    envvar)
-        COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
-                sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
-        ;;
-
-    *v@(isible|ersion)|match)
-        COMPREPLY=($(compgen $nospace -W '/' -- $cur))
-        ;;
-
-    # $prev is a path, so complete on category/package
-    */*)
-            local x a=0
-            for x in ${COMP_WORDS[@]} ; do
-                # This is the only one
-                if [[ "${x}" == "all_best_visible" ]] ; then
-                    a=1
-                    break
-                fi
-            done
-
-            if [[ ${a} -eq 1 ]] ; then
-                COMPREPLY=()
-            else
-                # Check for conditional.
-#                cond="${cur%%[A-Za-z0-9]*}"
-#                cur="${cur:${#cond}}"
-
-#                if [[ -n "${cond}" ]] ; then
-#                    _pkgname -A $cur
-#                else
-                    _pkgname -A $cur
-#                fi
-            fi
-        ;;
-    esac
-} &&
-complete -F _portageq portageq
-
-#
-# webapp-config completion
-#
-
-_webapp_complete_appver()
-{
-    local x proot ibase cur="$2"
-    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-        echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
-        echo ibase="${WA_INSTALLSBASE:-installs}")
-
-    case "$1" in
-    # complete on installed
-    installed)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/*/*/installs ; do \
-            if [[ -f "${x}" ]] ; then \
-            local y="${x%/*}" ; \
-            y="${y%/*}" ; \
-            echo "${y##*/}" ; \
-            fi ; \
-        done)" -- ${cur}))
-        ;;
-
-    # complete on uninstalled
-    uninstalled)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/*/* ; do \
-            if [[ ! -f "${x}/${ibase}" ]] ; then \
-            local y="${x%/*}" ; \
-            echo "${y##*/}" ; \
-            fi ; \
-        done)" -- ${cur}))
-        ;;
-
-    # all
-    all)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/* ; do \
-            [[ -d "${x}" ]] && echo "${x##*/}" ; \
-        done)" -- ${cur}))
-        ;;
-
-    # complete on version
-    *)
-        [[ -d "${proot}/$1" ]] || return 1
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/$1/* ; do \
-            [[ -d "${x}" ]] && echo "${x##*/}" ; \
-        done)" -- ${cur}))
-        ;;
-    esac
-}
-
-_webapp_config()
-{
-    local cur prev actions opts hostroot
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    actions="-I --install -U --upgrade -C --clean --list-installs \
-    --list-unused-installs --show-installed --show-postinst \
-    --help -v --version"
-    opts="--bug-report --pretend -p -u --user -g --group \
-    -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
-    --virtual-files --force-virtual"
-
-    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-    echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
-
-    # --bug-report, --pretend, and -p can only be used as first arg
-    if [[ ${COMP_CWORD} -gt 1 ]] ; then
-        opts="${opts/--bug-report --pretend -p}"
-    fi
-
-    if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        --bug-report|-p|--pretend)
-        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
-        ;;
-
-        -I|--install)
-            _webapp_complete_appver all ${cur}
-            ;;
-
-        -U|--upgrade)
-            _webapp_complete_appver installed ${cur}
-            ;;
-
-        # only complete on -d since it is required if -C is specified
-        -C|--clean)
-            COMPREPLY=($(compgen -W "-d" -- ${cur}))
-            ;;
-
-        --list-unused-installs)
-            _webapp_complete_appver uninstalled ${cur}
-            ;;
-
-        --list-installs|--show-postinst)
-            _webapp_complete_appver all ${cur}
-            ;;
-
-        #  hrm... anyone know a better way to reliably do this?
-        -h|--host)
-            local x
-            COMPREPLY=($(compgen -W "$(\
-                for x in ${hostroot}/* ; do \
-                    [[ -d "${x}" ]] && echo "${x##*/}" ; \
-                done)" -- ${cur}))
-            ;;
-
-        --virtual*)
-            COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
-            -- ${cur}))
-            ;;
-
-        -d|--dir)
-        local host x i=0
-                # see if --host has been specified, and if so, get the value
-                # that was passed to it.
-        for x in ${COMP_WORDS[@]} ; do
-            if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
-            host="${COMP_WORDS[((i+1))]}"
-            break
-            fi
-            i=$((i+1))
-        done
-
-                # otherwise, use the default host
-        if [[ "${host}" == "" ]] ; then
-            eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-            echo host="${VHOST_HOSTNAME:-localhost}")
-        fi
-
-            COMPREPLY=($(compgen -W "$(\
-            for x in ${hostroot}${host}/* ; do \
-            [[ -d "${x}" ]] && echo "${x}" ; \
-            done)" -- ${cur}))
-            ;;
-        -u|--user)
-            COMPREPLY=($(compgen -u -- ${cur}))
-            ;;
-        -g|--group)
-            COMPREPLY=($(compgen -g -- ${cur}))
-            ;;
-
-        # we haven't recognized it yet, so more than likely ${prev}
-        # is a 'app-name' ; assuming it is indeed a valid 'app-name'
-        # (_webapp_complete_appver does the check), complete on available
-        # 'app-version's
-        *)
-            _webapp_complete_appver ${prev} ${cur} || \
-                    _webapp_complete_appver all ${cur}
-            ;;
-    esac
-} &&
-complete -F _webapp_config webapp-config
-
-_revdep_rebuild() {
-    local cur prev numwords opts
-    local words i x
-    local action actionpos
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-            COMPREPLY=($(compgen -f -- ${cur}))
-            return 0
-        fi
-
-    # find action
-    for ((i = 0; i < ${numwords}; i++ )); do
-        case ${COMP_WORDS[${i}]} in
-            --library|-L)
-                action=${COMP_WORDS[${i}]}
-                actionpos=${i}
-                ;;
-            --help|-h)
-                action=${COMP_WORDS[${i}]}
-                actionpos=${i}
-                ;;
-        esac
-    done
-
-    if [[ ${cur} == -* ]]; then
-        if [[ ${cur} == --* ]]; then
-            opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        else
-            opts="-e -h -i -k -L -l -o -p -P -q -u -v"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        fi
-        return 0
-    fi
-    if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
-        if [[ "${cur}" == */* ]]; then
-            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
-        else
-            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
-        fi
-    fi
-    return 0
-} &&
-complete -F _revdep_rebuild revdep-rebuild
-
-_splat() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
-    --list -u --count -p --package -t --sort -r --reverse"
-
-    if [[ ${cur} == -* ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        -f|--logfile)
-            COMPREPLY=($(compgen -f -- ${cur}))
-            ;;
-        *)
-            _pkgname -A ${cur}
-            COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
-            ;;
-    esac
-} &&
-complete -o filenames -F _splat splat
-
-_euse() {
-    local cur prev opts sopts use portdir
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-h --help -v --version -i --info -I --info-installed -a --active
-        -E --enable -D --disable -P --prune"
-    sopts="-g --global -l --local"
-
-    if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        -h|--help|-v|--version)
-            COMPREPLY=()
-            ;;
-        -a|--active)
-            COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
-            ;;
-        -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
-            portdir=$(_portdir)
-        use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
-        $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
-        COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
-            ;;
-        *)
-            local l=0 g=0
-
-            if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
-                l=1
-            elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
-                g=1
-            fi
-
-            if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
-            then
-                portdir=$(_portdir)
-
-                if [[ ${l} -eq 1 ]] ; then
-                    use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
-                elif [[ ${g} -eq 1 ]] ; then
-                    use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
-                fi
-
-                COMPREPLY=($(compgen -W "${use}" -- ${cur}))
-            fi
-    esac
-} &&
-complete -F _euse euse
-
-_glsa_check() {
-    local cur opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
-    --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
-    -c --cve -m --mail"
-
-    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    # too slow otherwise
-    if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
-        [[ $(stat ${ROOT}/tmp/gc.out | \
-        sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
-    then
-        glsa-check -nl 2>/dev/null | \
-            sed -n -e  's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
-                ${ROOT}/tmp/gc.out
-    fi
-
-    COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
-} &&
-complete -F _glsa_check glsa-check
-
-_epm() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD]}"
-    opts="-q --query -V -y --verify -e --erase --help"
-
-    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        --help)
-            COMPREPLY=()
-            ;;
-        -q|--query)
-            _pkgname -I ${cur}
-            COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
-            ;;
-        *)
-            local x all=0 file=0
-            for x in ${COMP_WORDS[@]} ; do
-                [[ ${x} == -* ]] || continue
-                [[ ${x} == *f* ]] && file=1
-                [[ ${x} == *a* ]] && all=1
-            done
-
-            if [[ ${file} -eq 1 ]] ; then
-                COMPREPLY=($(compgen -f -- ${cur}))
-            elif [[ ${all} -eq 1 ]] ; then
-                COMPREPLY=()
-            else
-                _pkgname -I ${cur}
-            fi
-            ;;
-    esac
-} &&
-complete -o filenames -F _epm epm
-
-_metagen() {
-    local cur prev opts
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-    opts="$(_parse_help ${COMP_WORDS[0]})"
-
-    case $prev in
-        -h|--help|--version)
-            return 0
-            ;;
-        -H|-e|-n|-d|-l)
-            return 0
-            ;;
-        -o)
-            _filedir
-            return 0
-            ;;
-    esac
-
-    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-    return 0
-} &&
-complete -F _metagen metagen
-
-_rc_service() {
-    local cur prev numwords opts
-    local words i x filename
-    local action actionpos
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-            COMPREPLY=($(compgen -f -- ${cur}))
-            return 0
-        fi
-
-    # find action
-    for x in ${COMP_LINE} ; do
-        if [[ ${x} =~ --(list|exists|resolve) ]] || \
-            [[ ${x} =~ -(l|e|r) ]]
-        then
-            action=${x}
-            break
-        fi
-    done
-    if [[ -n ${action} ]]; then
-        for ((i = 0; i < ${numwords}; i++ )); do
-            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
-                actionpos=${i}
-                break
-            fi
-        done
-
-        for ((i = 1; i < ${numwords}; i++ )); do
-            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
-                break
-            fi
-        done
-    fi
-
-    if [[ ${COMP_CWORD} -eq 3 ]]; then
-        return 1
-    fi
-
-    # check if an option was typed
-    if [[ ${cur} == -* ]]; then
-        if [[ ${cur} == --* ]]; then
-            opts="--list --exists --resolve"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        elif [[ ${cur} == -* ]]; then
-            opts="-l -e -r"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-
-
-        # NOTE: This slows things down!
-        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
-        # This removes any options from the list of completions that have
-        # already been specified on the command line.
-        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
-        (while read -d ' ' i; do
-            [[ -z ${i} ]] && continue
-            # flatten array with spaces on either side,
-            # otherwise we cannot grep on word boundaries of
-            # first and last word
-            COMPREPLY=" ${COMPREPLY[@]} "
-            # remove word from list of completions
-            COMPREPLY=(${COMPREPLY/ ${i%% *} / })
-        done
-        echo ${COMPREPLY[@]})))
-
-            return 0
-    # if no option typed
-    else
-        if [[ ${COMP_CWORD} -eq 1 ]]; then              # if first word typed
-            words="`rc-service -l | grep ^${cur}`"          # complete for init scripts
-            COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-            done))
-            return 0
-        elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
-            filename=`rc-service -r ${prev}`
-            opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"`    # Greps the functions included in the init script
-            if [[ "x${opts}" == "x" ]] ; then               # if no options found loosen the grep algorhythm
-                opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
-            fi
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-    fi
-    if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
-          [[ ${action} == '--resolve' ]]  || [[ ${action} == '-r' ]]; then
-        words="`rc-service -l | grep ^${cur}`"
-        COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-        done))
-        return 0
-    fi
-
-    return 0
-} &&
-complete -F _rc_service rc-service
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/glsa-check b/completions/glsa-check
new file mode 100644
index 0000000..76f6466
--- /dev/null
+++ b/completions/glsa-check
@@ -0,0 +1,33 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_glsa_check() {
+    local cur opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
+    --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
+    -c --cve -m --mail"
+
+    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    # too slow otherwise
+    if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
+        [[ $(stat ${ROOT}/tmp/gc.out | \
+        sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
+    then
+        glsa-check -nl 2>/dev/null | \
+            sed -n -e  's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
+                ${ROOT}/tmp/gc.out
+    fi
+
+    COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
+} &&
+complete -F _glsa_check glsa-check
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/java-config b/completions/java-config
new file mode 100644
index 0000000..42bf11e
--- /dev/null
+++ b/completions/java-config
@@ -0,0 +1,158 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# java-config completion command
+#
+_javaconfig()
+{
+    local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
+    local multiplepkgs pkgs execopts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    opts=""
+    args=""
+    pkgs=""
+    sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
+    vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
+    grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
+    multiplepkgs=""
+    execopts="HtmlConverter JavaPluginControlPanel \
+    appletviewer awt_robot \
+    extcheck \
+    idlj \
+    j2sdk-config jar jarsigner \
+    java java-rmi.cgi java_vm javac javadoc javah javap jdb \
+    keytool kinit klist ktab \
+    native2ascii \
+    oldjava oldjavac oldjdb orbd \
+    policytool \
+    realpath rmic rmid rmiregistry \
+    serialver servertool \
+        tnameserv"
+    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
+    case "${cur}" in
+        --java)
+        opts="--java --javac --java-version"
+        ;;
+        --j@(a@(r|va@(c|-version))|@(dk|re)-home))
+        opts=""
+        ;;
+        --list-available-@(packages|vms))
+        opts=""
+        ;;
+        --@(exec|set-@(user|system)-@(classpath|vm)))
+        opts="${cur}="
+        ;;
+        --set-@(user|system)-@(classpath|vm)=)
+        if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
+            flag="--list-available-vms"
+            args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
+        else
+            flag="--list-available-packages"
+            args=$(java-config --nocolor "${flag}" | ${sedcmd})
+        fi
+        for arg in ${args}; do
+            [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+        done
+        COMPREPLY=($(compgen $nospace -W "${opts}"))
+        return 0
+        ;;
+        --exec=)
+        COMPREPLY=($(compgen $nospace -W "${execopts}"))
+        return 0
+        ;;
+        *)
+            if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
+            args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
+            if [[ "${cur}" == "--set-system-vm="* ]]; then
+            spec=${cur##--set-system-vm=}
+            else
+            spec=${cur##--set-user-vm=}
+            fi
+            for arg in ${args}; do
+            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+            fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
+            args=$(java-config --nocolor --list-available-packages | ${sedcmd})
+            [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
+            if [[ "${cur}" == "--set-system-classpath="* ]]; then
+            spec="${cur##--set-system-classpath=}"
+            else
+            spec="${cur##--set-user-classpath=}"
+            fi
+            if [[ -n "${multiplepkgs}" ]]; then
+            pkgs="${spec%,*}"
+            spec="${spec##*,}"
+            fi
+            if [[ -n "${multiplepkgs}" ]]; then
+                for arg in ${args}; do
+                if [[ "${spec}" ]]; then
+                    if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
+                        && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
+                                then
+                    [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
+                    fi
+                else
+                    if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
+                        [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
+                    fi
+                fi
+                done
+            [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
+            else
+                for arg in ${args}; do
+                if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+                fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            fi
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        elif [[ "${cur}" == "--exec="* ]]; then
+            spec=${cur##--exec=}
+            for arg in ${execopts}; do
+            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+            fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        else
+            opts="--classpath --clean-system-classpath --clean-user-classpath \
+                --exec \
+            --full-classpath \
+                --jar --java --javac --java-version --jdk-home --jre-home \
+                --list-available-packages --list-available-vms \
+            --nocolor \
+            --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
+            [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
+        fi
+            ;;
+        esac
+    elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
+    opts="--classpath --clean-system-classpath --clean-user-classpath \
+        --exec \
+        --full-classpath \
+        --jar --java --javac --java-version --jdk-home --jre-home \
+        --list-available-packages --list-available-vms \
+        --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
+    fi
+    COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
+    return 0
+} &&
+complete $nospace -F _javaconfig java-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/metagen b/completions/metagen
new file mode 100644
index 0000000..3ba0dc9
--- /dev/null
+++ b/completions/metagen
@@ -0,0 +1,30 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_metagen() {
+    local cur prev opts
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    opts="$(_parse_help ${COMP_WORDS[0]})"
+
+    case $prev in
+        -h|--help|--version)
+            return 0
+            ;;
+        -H|-e|-n|-d|-l)
+            return 0
+            ;;
+        -o)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+    return 0
+} &&
+complete -F _metagen metagen
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/portageq b/completions/portageq
new file mode 100644
index 0000000..7922e59
--- /dev/null
+++ b/completions/portageq
@@ -0,0 +1,87 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# portageq completion
+#
+
+_portageq() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    opts="config_protect_mask \
+      config_protect \
+      vdb_path \
+      gentoo_mirrors \
+      all_best_visible \
+      match \
+      best_visible \
+      mass_best_visible \
+      has_version \
+      portdir \
+      envvar \
+      mass_best_version \
+      best_version \
+      pkgdir \
+      portdir_overlay \
+      distdir"
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+    # would always be correct, but it's pretty slow...
+    #COMPREPLY=($(compgen -W "$(portageq | grep '^   [[:lower:]]' | \
+    #    sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
+    #    -- ${cur}))
+    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+    fi
+
+    case "${prev}" in
+    config*|vdb_path|gentoo_mirrors|*dir*)
+        COMPREPLY=()
+        ;;
+
+    # this also isn't the fastest, but I welcome an alternative method
+    envvar)
+        COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
+                sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
+        ;;
+
+    *v@(isible|ersion)|match)
+        COMPREPLY=($(compgen $nospace -W '/' -- $cur))
+        ;;
+
+    # $prev is a path, so complete on category/package
+    */*)
+            local x a=0
+            for x in ${COMP_WORDS[@]} ; do
+                # This is the only one
+                if [[ "${x}" == "all_best_visible" ]] ; then
+                    a=1
+                    break
+                fi
+            done
+
+            if [[ ${a} -eq 1 ]] ; then
+                COMPREPLY=()
+            else
+                # Check for conditional.
+#                cond="${cur%%[A-Za-z0-9]*}"
+#                cur="${cur:${#cond}}"
+
+#                if [[ -n "${cond}" ]] ; then
+#                    _pkgname -A $cur
+#                else
+                    _pkgname -A $cur
+#                fi
+            fi
+        ;;
+    esac
+} &&
+complete -F _portageq portageq
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc b/completions/rc
new file mode 100644
index 0000000..7453ed4
--- /dev/null
+++ b/completions/rc
@@ -0,0 +1,21 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc completion command
+#
+_rc()
+{
+    local cur
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
+    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    fi
+    return 0
+} &&
+complete -F _rc rc
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-service b/completions/rc-service
new file mode 100644
index 0000000..9ad2ce1
--- /dev/null
+++ b/completions/rc-service
@@ -0,0 +1,111 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_rc_service() {
+    local cur prev numwords opts
+    local words i x filename
+    local action actionpos
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+            COMPREPLY=($(compgen -f -- ${cur}))
+            return 0
+        fi
+
+    # find action
+    for x in ${COMP_LINE} ; do
+        if [[ ${x} =~ --(list|exists|resolve) ]] || \
+            [[ ${x} =~ -(l|e|r) ]]
+        then
+            action=${x}
+            break
+        fi
+    done
+    if [[ -n ${action} ]]; then
+        for ((i = 0; i < ${numwords}; i++ )); do
+            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
+                actionpos=${i}
+                break
+            fi
+        done
+
+        for ((i = 1; i < ${numwords}; i++ )); do
+            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
+                break
+            fi
+        done
+    fi
+
+    if [[ ${COMP_CWORD} -eq 3 ]]; then
+        return 1
+    fi
+
+    # check if an option was typed
+    if [[ ${cur} == -* ]]; then
+        if [[ ${cur} == --* ]]; then
+            opts="--list --exists --resolve"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        elif [[ ${cur} == -* ]]; then
+            opts="-l -e -r"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        fi
+
+
+        # NOTE: This slows things down!
+        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
+        # This removes any options from the list of completions that have
+        # already been specified on the command line.
+        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
+        (while read -d ' ' i; do
+            [[ -z ${i} ]] && continue
+            # flatten array with spaces on either side,
+            # otherwise we cannot grep on word boundaries of
+            # first and last word
+            COMPREPLY=" ${COMPREPLY[@]} "
+            # remove word from list of completions
+            COMPREPLY=(${COMPREPLY/ ${i%% *} / })
+        done
+        echo ${COMPREPLY[@]})))
+
+            return 0
+    # if no option typed
+    else
+        if [[ ${COMP_CWORD} -eq 1 ]]; then              # if first word typed
+            words="`rc-service -l | grep ^${cur}`"          # complete for init scripts
+            COMPREPLY=($(for i in ${words} ; do \
+            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+            done))
+            return 0
+        elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
+            filename=`rc-service -r ${prev}`
+            opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"`    # Greps the functions included in the init script
+            if [[ "x${opts}" == "x" ]] ; then               # if no options found loosen the grep algorhythm
+                opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
+            fi
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        fi
+    fi
+    if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
+          [[ ${action} == '--resolve' ]]  || [[ ${action} == '-r' ]]; then
+        words="`rc-service -l | grep ^${cur}`"
+        COMPREPLY=($(for i in ${words} ; do \
+            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+        done))
+        return 0
+    fi
+
+    return 0
+} &&
+complete -F _rc_service rc-service
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-status b/completions/rc-status
new file mode 100644
index 0000000..794067f
--- /dev/null
+++ b/completions/rc-status
@@ -0,0 +1,28 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc-status completion command
+#
+_rcstatus()
+{
+    local cur
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ $COMP_CWORD -eq 1 ]]; then
+        if [[ "${cur}" == --* ]]; then
+        COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
+    elif [[ "${cur}" == -* ]]; then
+        COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
+    else
+        COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
+    fi
+    else
+    unset COMPREPLY
+    fi
+    return 0
+} &&
+complete -F _rcstatus rc-status
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-update b/completions/rc-update
new file mode 100644
index 0000000..ae45744
--- /dev/null
+++ b/completions/rc-update
@@ -0,0 +1,40 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc-update completion command
+#
+_rcupdate()
+{
+    local cur show
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ $COMP_CWORD -eq 1 ]]; then
+    if [[ "${cur}" == -* ]]; then
+        COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
+    else
+        COMPREPLY=($(compgen -W 'add del show' ${cur}))
+    fi
+    else
+        if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
+        show="TRUE"
+    fi
+    if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
+            ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
+        then
+        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    elif [[ $COMP_CWORD -eq 2 ]]; then
+        COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
+    elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
+        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    else
+        unset COMPREPLY
+    fi
+    fi
+    return 0
+} &&
+complete -F _rcupdate rc-update
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/revdep-rebuild b/completions/revdep-rebuild
new file mode 100644
index 0000000..cb0efe7
--- /dev/null
+++ b/completions/revdep-rebuild
@@ -0,0 +1,55 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_revdep_rebuild() {
+    local cur prev numwords opts
+    local words i x
+    local action actionpos
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+            COMPREPLY=($(compgen -f -- ${cur}))
+            return 0
+        fi
+
+    # find action
+    for ((i = 0; i < ${numwords}; i++ )); do
+        case ${COMP_WORDS[${i}]} in
+            --library|-L)
+                action=${COMP_WORDS[${i}]}
+                actionpos=${i}
+                ;;
+            --help|-h)
+                action=${COMP_WORDS[${i}]}
+                actionpos=${i}
+                ;;
+        esac
+    done
+
+    if [[ ${cur} == -* ]]; then
+        if [[ ${cur} == --* ]]; then
+            opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        else
+            opts="-e -h -i -k -L -l -o -p -P -q -u -v"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        fi
+        return 0
+    fi
+    if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
+        if [[ "${cur}" == */* ]]; then
+            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
+        else
+            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
+        fi
+    fi
+    return 0
+} &&
+complete -F _revdep_rebuild revdep-rebuild
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/splat b/completions/splat
new file mode 100644
index 0000000..ddae6a0
--- /dev/null
+++ b/completions/splat
@@ -0,0 +1,33 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_splat() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
+    --list -u --count -p --package -t --sort -r --reverse"
+
+    if [[ ${cur} == -* ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        -f|--logfile)
+            COMPREPLY=($(compgen -f -- ${cur}))
+            ;;
+        *)
+            _pkgname -A ${cur}
+            COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
+            ;;
+    esac
+} &&
+complete -o filenames -F _splat splat
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/webapp-config b/completions/webapp-config
new file mode 100644
index 0000000..01679b5
--- /dev/null
+++ b/completions/webapp-config
@@ -0,0 +1,169 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# webapp-config completion
+#
+
+_webapp_complete_appver()
+{
+    local x proot ibase cur="$2"
+    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+        echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
+        echo ibase="${WA_INSTALLSBASE:-installs}")
+
+    case "$1" in
+    # complete on installed
+    installed)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/*/*/installs ; do \
+            if [[ -f "${x}" ]] ; then \
+            local y="${x%/*}" ; \
+            y="${y%/*}" ; \
+            echo "${y##*/}" ; \
+            fi ; \
+        done)" -- ${cur}))
+        ;;
+
+    # complete on uninstalled
+    uninstalled)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/*/* ; do \
+            if [[ ! -f "${x}/${ibase}" ]] ; then \
+            local y="${x%/*}" ; \
+            echo "${y##*/}" ; \
+            fi ; \
+        done)" -- ${cur}))
+        ;;
+
+    # all
+    all)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/* ; do \
+            [[ -d "${x}" ]] && echo "${x##*/}" ; \
+        done)" -- ${cur}))
+        ;;
+
+    # complete on version
+    *)
+        [[ -d "${proot}/$1" ]] || return 1
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/$1/* ; do \
+            [[ -d "${x}" ]] && echo "${x##*/}" ; \
+        done)" -- ${cur}))
+        ;;
+    esac
+}
+
+_webapp_config()
+{
+    local cur prev actions opts hostroot
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    actions="-I --install -U --upgrade -C --clean --list-installs \
+    --list-unused-installs --show-installed --show-postinst \
+    --help -v --version"
+    opts="--bug-report --pretend -p -u --user -g --group \
+    -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
+    --virtual-files --force-virtual"
+
+    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+    echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
+
+    # --bug-report, --pretend, and -p can only be used as first arg
+    if [[ ${COMP_CWORD} -gt 1 ]] ; then
+        opts="${opts/--bug-report --pretend -p}"
+    fi
+
+    if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        --bug-report|-p|--pretend)
+        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
+        ;;
+
+        -I|--install)
+            _webapp_complete_appver all ${cur}
+            ;;
+
+        -U|--upgrade)
+            _webapp_complete_appver installed ${cur}
+            ;;
+
+        # only complete on -d since it is required if -C is specified
+        -C|--clean)
+            COMPREPLY=($(compgen -W "-d" -- ${cur}))
+            ;;
+
+        --list-unused-installs)
+            _webapp_complete_appver uninstalled ${cur}
+            ;;
+
+        --list-installs|--show-postinst)
+            _webapp_complete_appver all ${cur}
+            ;;
+
+        #  hrm... anyone know a better way to reliably do this?
+        -h|--host)
+            local x
+            COMPREPLY=($(compgen -W "$(\
+                for x in ${hostroot}/* ; do \
+                    [[ -d "${x}" ]] && echo "${x##*/}" ; \
+                done)" -- ${cur}))
+            ;;
+
+        --virtual*)
+            COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
+            -- ${cur}))
+            ;;
+
+        -d|--dir)
+        local host x i=0
+                # see if --host has been specified, and if so, get the value
+                # that was passed to it.
+        for x in ${COMP_WORDS[@]} ; do
+            if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
+            host="${COMP_WORDS[((i+1))]}"
+            break
+            fi
+            i=$((i+1))
+        done
+
+                # otherwise, use the default host
+        if [[ "${host}" == "" ]] ; then
+            eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+            echo host="${VHOST_HOSTNAME:-localhost}")
+        fi
+
+            COMPREPLY=($(compgen -W "$(\
+            for x in ${hostroot}${host}/* ; do \
+            [[ -d "${x}" ]] && echo "${x}" ; \
+            done)" -- ${cur}))
+            ;;
+        -u|--user)
+            COMPREPLY=($(compgen -u -- ${cur}))
+            ;;
+        -g|--group)
+            COMPREPLY=($(compgen -g -- ${cur}))
+            ;;
+
+        # we haven't recognized it yet, so more than likely ${prev}
+        # is a 'app-name' ; assuming it is indeed a valid 'app-name'
+        # (_webapp_complete_appver does the check), complete on available
+        # 'app-version's
+        *)
+            _webapp_complete_appver ${prev} ${cur} || \
+                    _webapp_complete_appver all ${cur}
+            ;;
+    esac
+} &&
+complete -F _webapp_config webapp-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2018-03-02 18:06 Michał Górny
  2014-08-31 21:19 ` Michał Górny
  0 siblings, 1 reply; 34+ messages in thread
From: Michał Górny @ 2018-03-02 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     1781d5b81021858db447d4c63f68e081e320fd00
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 31 19:18:57 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Aug 31 19:18:57 2014 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=1781d5b8

Split completions by completed command.

 completions/browser-config |   31 +
 completions/distcc-config  |   41 ++
 completions/ebuild         |   34 +
 completions/ekeyword       |   46 ++
 completions/emerge         |  410 +++++++++++
 completions/epkginfo       |   28 +
 completions/epm            |   48 ++
 completions/equery         |  280 ++++++++
 completions/euse           |   60 ++
 completions/gcc-config     |   45 ++
 completions/gentoo         | 1652 --------------------------------------------
 completions/glsa-check     |   33 +
 completions/java-config    |  158 +++++
 completions/metagen        |   30 +
 completions/portageq       |   87 +++
 completions/rc             |   21 +
 completions/rc-service     |  111 +++
 completions/rc-status      |   28 +
 completions/rc-update      |   40 ++
 completions/revdep-rebuild |   55 ++
 completions/splat          |   33 +
 completions/webapp-config  |  169 +++++
 22 files changed, 1788 insertions(+), 1652 deletions(-)

diff --git a/completions/browser-config b/completions/browser-config
new file mode 100644
index 0000000..158ca42
--- /dev/null
+++ b/completions/browser-config
@@ -0,0 +1,31 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# browser-config completion command
+#
+_browserconfig()
+{
+    local cur prev
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    if [[ ${COMP_CWORD} -eq 1 ]]; then
+    COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
+    elif [[ "${prev}" == "-b" ]]; then
+    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
+    elif [[ "${prev}" == "-m" ]]; then
+        COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
+    if [[ -z "${COMPREPLY}" ]]; then
+        COMPREPLY=''
+    fi
+    else
+    unset COMPREPLY
+    fi
+    return 0
+} &&
+complete -F _browserconfig browser-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/distcc-config b/completions/distcc-config
new file mode 100644
index 0000000..41c315f
--- /dev/null
+++ b/completions/distcc-config
@@ -0,0 +1,41 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# distcc-config completion command
+#
+_distccconfig()
+{
+    local cur curword numwords opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    if [[ ${numwords} -gt 3 ]]; then
+    unset COMPREPLY
+    return 0
+    fi
+    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
+    if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
+        opts="--get-hosts \
+        --get-verbose \
+        --get-log \
+        --set-hosts \
+        --set-verbose \
+        --set-log \
+        --add-path \
+        --no-path"
+    else
+        opts=""
+    fi
+    else
+    opts=""
+    fi
+    COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
+    return 0
+} &&
+complete -F _distccconfig distcc-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/ebuild b/completions/ebuild
new file mode 100644
index 0000000..cd6e17e
--- /dev/null
+++ b/completions/ebuild
@@ -0,0 +1,34 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# ebuild completion command
+#
+_ebuild()
+{
+    local cur opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+
+    opts="help setup clean fetch digest manifest unpack compile test preinst \
+        install postinst qmerge merge unmerge prerm postrm config package rpm \
+        configure prepare"
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
+            $(compgen -d -- ${cur}) \
+            $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
+
+    elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
+    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
+
+    elif [[ $COMP_CWORD -ge 2 ]] ; then
+    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+    fi
+    return 0
+} &&
+complete -o filenames -F _ebuild ebuild
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/ekeyword b/completions/ekeyword
new file mode 100644
index 0000000..3bf3006
--- /dev/null
+++ b/completions/ekeyword
@@ -0,0 +1,46 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# ekeyword completion
+#
+
+_ekeyword()
+{
+    local cur portdir archl_s archl_u archl_r archl_m arch
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    portdir=$(_portdir)
+
+    [[ -f ${portdir}/profiles/arch.list ]] || return 0
+
+    for arch in all $(< ${portdir}/profiles/arch.list) ; do
+        archl_m="${archl_m} -${arch}"
+        archl_u="${archl_u} ~${arch}"
+        archl_r="${archl_r} ^${arch}"
+        archl_s="${archl_s}  ${arch}"
+    done
+
+    case ${cur} in
+        -*)
+            COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
+            ;;
+        ~*)
+            COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
+            ;;
+        ^*)
+            COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
+            ;;
+        *)
+            COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
+            _filedir 'ebuild'
+            ;;
+        esac
+} &&
+complete -o filenames -F _ekeyword ekeyword
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/emerge b/completions/emerge
new file mode 100644
index 0000000..63c02b4
--- /dev/null
+++ b/completions/emerge
@@ -0,0 +1,410 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# emerge completion command
+#
+_emerge()
+{
+    local c cur prev curword numwords opts cond prepend
+    local words stophere i x
+    local action actionpos sysactions pkgpos
+    local portdir=$(_portdir -o)
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    opts=''
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+        COMPREPLY=($(compgen -f -- ${cur}))
+        return 0
+    fi
+
+    # find action
+    for x in ${COMP_LINE} ; do
+        if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
+            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
+        then
+            action=${x}
+            break
+        fi
+    done
+
+    if [[ -n ${action} ]]; then
+        for ((i = 0; i < ${numwords}; i++ )); do
+            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
+                actionpos=${i}
+                pkgpos=$((actionpos + 1))
+                break
+            fi
+        done
+
+        if [[ ${action} == -* && ${action} != --* ]] ; then
+            case "${action}" in
+            -*C*) action='--unmerge' ;;
+            -*P*) action='--prune' ;;
+            -*c*) action='--clean' ;;
+            -*s*) action='--search' ;;
+            esac
+        fi
+    else
+        for ((i = 1; i < ${numwords}; i++ )); do
+            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
+                pkgpos=${i}
+                break
+            fi
+        done
+        [[ -z ${pkgpos} ]] && pkgpos=${numwords}
+    fi
+
+    # Handle special cases.
+    if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
+        [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
+    then
+        unset COMPREPLY
+        return 0
+    elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
+        unset COMPREPLY
+        [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
+        return 0
+    fi
+
+    # Complete on options.
+    if [[ ${cur} == -* ]]; then
+        # If a resume option was specified, it needs special handling.
+        if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
+            if [[ ${cur} == --* ]]; then
+                opts="--ask --pretend --resume --skipfirst"
+            elif [[ ${cur} == -* ]]; then
+                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
+            fi
+        elif [[ ${cur} == --* ]]; then
+            # Complete on long options.
+            opts="--alphabetical --ask \
+                --buildpkg --buildpkgonly \
+                --changelog --clean --color=y --color=n --columns --complete-graph --config \
+                --debug --deep --depclean \
+                --emptytree \
+                --fetch-all-uri --fetchonly \
+                --getbinpkg --getbinpkgonly \
+                --ignore-default-opts --info \
+                --jobs= \
+                --keep-going \
+                --metadata \
+                --newuse --noconfmem --nodeps --noreplace --nospinner \
+                --oneshot --onlydeps \
+                --pretend --prune \
+                --quiet \
+                --reinstall=changed-use --regen \
+                --search \
+                --sync \
+                --tree \
+                --unmerge --update --upgradeonly --usepkg --usepkgonly \
+                --verbose \
+                --with-bdeps=y --with-bdeps=n"
+            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
+                opts="${opts} --help --resume --searchdesc --version"
+            fi
+        elif [[ ${cur} == -* ]]; then
+            # Complete on short options.
+            opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
+            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
+                opts="${opts} -h -S -V"
+            fi
+            if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
+                opts="${opts} -C -P -c -s"
+            fi
+        fi
+
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+
+        # NOTE: This slows things down!
+        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
+        # This removes any options from the list of completions that have
+        # already been specified on the command line.
+        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
+            (while read -d ' ' i; do
+                [[ -z ${i} ]] && continue
+                # flatten array with spaces on either side,
+                # otherwise we cannot grep on word boundaries of
+                # first and last word
+                COMPREPLY=" ${COMPREPLY[@]} "
+                # remove word from list of completions
+                COMPREPLY=(${COMPREPLY/ ${i%% *} / })
+            done
+            echo ${COMPREPLY[@]})))
+
+        return 0
+    fi # options
+
+    # Stop completion if a special case is encountered.
+    if [[ ${action} =~ (system|world) ]] || \
+        [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
+    then
+        unset COMPREPLY
+        return 0
+    fi
+
+    # Complete on installed packages when unmerging.
+    if [[ "${action}" == '--unmerge' ]]; then
+    if [[ -n "${cur}" ]] ; then
+        if [[ "${cur}" == */* ]]; then
+        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
+        else
+        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
+
+                local n=0
+                for i in ${words} ; do
+                    [[ ${i} == ${cur}* ]] && n=$((n+1))
+                done
+
+                if [[ ${n} -eq 1 ]] ; then
+                    words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
+                fi
+        fi
+            COMPREPLY=($(for i in ${words} ; do \
+                            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+                        done))
+    else
+        COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
+    fi
+
+        [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
+        return 0
+    fi
+
+    # Check for conditional.
+    cond="${cur%%[A-Za-z0-9]*}"
+    cur="${cur:${#cond}}"
+    if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
+        prepend="-P ${cond:1}"
+        c="${cond:1}"
+    else
+        c="${cond}"
+    fi
+
+    # Handle cases where a conditional is specified.
+    if [[ -n "${cond}" ]]; then
+    if [[ -n "${cur}" ]]; then
+            if [[ ${cur} == */* ]]; then
+                if [[ ${cur} == *-[0-9]* ]] ; then
+                    words="$(\
+                        for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            local cat="${cur%/*}" ; \
+                            local pkg="$(echo ${cur%-[0-9]*})" ; \
+                            pkg="${pkg##*/}" ; \
+                            for x in ${cat}/${pkg}/*.ebuild ; do \
+                                [[ -f ${x} ]] || continue ; \
+                                x="${x/${pkg}\/}" ; \
+                                echo "${x%*.ebuild}" ; \
+                            done ; \
+                        done)"
+                else
+            words="$(\
+                    for pd in ${portdir} ; do \
+                        builtin cd ${pd}; \
+                        compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
+                    done)"
+                fi
+
+                local w
+                for x in $words ; do
+                    w="${x}\n${w}"
+                done
+
+                words=$(echo -ne ${w} | sort | uniq)
+                COMPREPLY=( ${words} )
+
+                # Complete on the specific versions (if appropriate).
+                # TODO - see if we can use _pkgname
+                if [[ ${#COMPREPLY[@]} -le 1 ]]; then
+                    COMPREPLY=($(
+                        for pd in ${portdir}; do
+                            if [[ -d ${pd}/metadata/md5-cache ]]; then
+                                builtin cd ${pd}/metadata/md5-cache
+                                compgen ${prepend} -G "${cur}*" -- "${cur}"
+                            elif [[ -d ${pd}/metadata/cache ]]; then
+                                builtin cd ${pd}/metadata/cache
+                                compgen ${prepend} -G "${cur}*" -- "${cur}"
+                            else
+                                builtin cd ${pd}
+                                local cat="${cur%/*}"
+                                local pkg="$(echo ${cur%-[0-9]*}*)"
+                                pkg="${pkg##*/}"
+                                for x in ${cat}/${pkg}/*.ebuild; do
+                                    [[ -f "${x}" ]] || continue
+                                    x="${x/${pkg}\/}"
+                                    if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
+                                        echo "${c}${x%*.ebuild}"
+                                    else
+                                        echo "${x%*.ebuild}"
+                                    fi
+                                done
+                            fi
+                        done
+                    ))
+                else
+                    COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
+                fi
+            else
+                words="$(\
+                    for pd in ${portdir} ; do \
+                        builtin cd ${pd} ; \
+                        compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
+                    done)"
+
+                local w
+                for x in words ; do
+                    w="${x}\n${w}"
+                done
+
+                COMPREPLY=($(echo -e ${w} | uniq))
+                [[ ${#COMPREPLY[@]} = 1 ]] && \
+                    COMPREPLY=($(\
+                        for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
+                        done))
+            fi
+        else
+        words="$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    compgen -G "*-*"; \
+                done)"
+        COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
+    fi
+
+        # If all else fails, try to complete on package names without the
+    # category being specified.
+    if [[ -z "${COMPREPLY}" ]]; then
+        words="$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    for i in *-*/${cur}*; do \
+                        [[ -d $i ]] && echo ${i##*/}; \
+                    done ; \
+                done)"
+
+        COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
+
+        if [[ ${#COMPREPLY[@]} -le 1 ]]; then
+            # Now complete on the specific versions.
+            words="$(
+                for pd in ${portdir}; do
+                    if [[ -d ${pd}/metadata/md5-cache ]]; then
+                        builtin cd ${pd}/metadata/md5-cache
+                        for i in */${cur}*; do
+                            [[ -f $i ]] && echo ${i##*/}
+                        done
+                    elif [[ -d ${pd}/metadata/cache ]]; then
+                        builtin cd ${pd}/metadata/cache
+                        for i in */${cur}*; do
+                            [[ -f $i ]] && echo ${i##*/}
+                        done
+                    fi
+                done
+            )"
+            COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
+        fi
+    fi
+    return 0
+    fi
+
+    # Complete on packages.
+    #
+    # Only allow these actions if no packages have been specified.
+    #
+    # TODO: This doesn't block these actions if no categories are
+    #       specified. Please fix me.
+    #
+    #       e.g. emerge -a gentoo-dev-sources
+    #
+    #            will still allow system and world actions to be specified,
+    #            as opposed to
+    #
+    #            emerge -a sys-kernel/gentoo-dev-sources
+    #
+    if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
+        sysactions=$'\n'"system"$'\n'"world"
+    else
+        sysactions=''
+    fi
+
+    if [[ -n "${cur}" ]] ; then
+        if [[ ${cur} == */* ]] ; then
+            words=$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd}; \
+                    compgen -X "*metadata.xml" -G "${cur}*" ; \
+                done)"${sysactions}"
+        else
+            local ww=$(\
+                for pd in ${portdir} ; do \
+                    builtin cd ${pd} ; \
+                    compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
+                done)"${sysactions}"
+            # complete on virtuals
+            ww="${ww} $(\
+                for pd in ${portdir} ; do \
+                    if [[ -d ${pd}/profiles ]] ; then
+                        find ${pd}/profiles -name virtuals -exec \
+                            sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
+                            sort -u
+                    fi ; \
+                done)"
+
+            local w
+            for x in ${ww} ; do w="${x}\n${w}" ; done
+
+            words=$(echo -e ${w} | sort -u)
+
+            local n=0
+            for i in ${words} ; do
+                [[ ${i} == ${cur}* ]] && n=$((n+1))
+            done
+
+            if [[ ${n} -eq 1 ]] ; then
+                words=$(for pd in ${portdir} ; do \
+                            builtin cd ${pd} ; \
+                            compgen -G "*-*/*" ; \
+                        done)"${sysactions}"
+            fi
+        fi
+        COMPREPLY=($(for i in ${words} ; do \
+                        [[ ${i} == ${cur}* ]] && echo ${i} ; \
+                    done))
+    else
+        words="$(\
+            for pd in ${portdir} ; do \
+                builtin cd ${pd} ; \
+                compgen -S '/' -G "*-*" ; \
+            done)""${sysactions}"
+    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+    fi
+
+    # If all else fails, try to complete on package names without the
+    # category being specified.
+    if [[ -z "${COMPREPLY}" ]]; then
+        words="$(\
+            for pd in ${portdir} ; do \
+                builtin cd ${pd}; \
+                for i in [a-z]*-[a-z0-9]*/${cur}*; do \
+                    [[ -d $i ]] && echo ${i##*/}; \
+                done ; \
+            done)"
+    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+    fi
+
+    return 0
+} &&
+complete -o filenames -F _emerge emerge
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/epkginfo b/completions/epkginfo
new file mode 100644
index 0000000..34c81f3
--- /dev/null
+++ b/completions/epkginfo
@@ -0,0 +1,28 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# epkginfo completion
+#
+
+_epkginfo()
+{
+    local cur prev
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    # Only complete if the previous entry on the command line is not
+    # a package name.
+    if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
+        _equery_meta $cur
+    fi
+
+    return 0
+} &&
+complete -F _epkginfo epkginfo
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/epm b/completions/epm
new file mode 100644
index 0000000..e8a8caa
--- /dev/null
+++ b/completions/epm
@@ -0,0 +1,48 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_epm() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD]}"
+    opts="-q --query -V -y --verify -e --erase --help"
+
+    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        --help)
+            COMPREPLY=()
+            ;;
+        -q|--query)
+            _pkgname -I ${cur}
+            COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
+            ;;
+        *)
+            local x all=0 file=0
+            for x in ${COMP_WORDS[@]} ; do
+                [[ ${x} == -* ]] || continue
+                [[ ${x} == *f* ]] && file=1
+                [[ ${x} == *a* ]] && all=1
+            done
+
+            if [[ ${file} -eq 1 ]] ; then
+                COMPREPLY=($(compgen -f -- ${cur}))
+            elif [[ ${all} -eq 1 ]] ; then
+                COMPREPLY=()
+            else
+                _pkgname -I ${cur}
+            fi
+            ;;
+    esac
+} &&
+complete -o filenames -F _epm epm
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

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

diff --git a/completions/euse b/completions/euse
new file mode 100644
index 0000000..e7bed0a
--- /dev/null
+++ b/completions/euse
@@ -0,0 +1,60 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_euse() {
+    local cur prev opts sopts use portdir
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help -v --version -i --info -I --info-installed -a --active
+        -E --enable -D --disable -P --prune"
+    sopts="-g --global -l --local"
+
+    if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        -h|--help|-v|--version)
+            COMPREPLY=()
+            ;;
+        -a|--active)
+            COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
+            ;;
+        -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
+            portdir=$(_portdir)
+        use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
+        $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
+        COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
+            ;;
+        *)
+            local l=0 g=0
+
+            if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
+                l=1
+            elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
+                g=1
+            fi
+
+            if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
+            then
+                portdir=$(_portdir)
+
+                if [[ ${l} -eq 1 ]] ; then
+                    use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
+                elif [[ ${g} -eq 1 ]] ; then
+                    use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
+                fi
+
+                COMPREPLY=($(compgen -W "${use}" -- ${cur}))
+            fi
+    esac
+} &&
+complete -F _euse euse
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/gcc-config b/completions/gcc-config
new file mode 100644
index 0000000..80e95c3
--- /dev/null
+++ b/completions/gcc-config
@@ -0,0 +1,45 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# gcc-config completion command
+#
+_gcc_config() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-O --use-old \
+        -P --use-portage-chost \
+        -c --get-current-profile \
+        -l --list-profiles \
+        -E --print-environ \
+        -B --get-bin-path \
+        -L --get-lib-path \
+        -X --get-stdcxx-incdir"
+
+    if [[ "${cur}" == -* ]] ; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    elif [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
+            $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
+                -- ${cur}) )
+        return 0
+    fi
+
+    case "${prev}" in
+        -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
+            COMPREPLY=()
+            ;;
+        *)
+            COMPREPLY=( $(compgen -W "\
+                $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
+            ;;
+    esac
+} &&
+complete -F _gcc_config gcc-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/gentoo b/completions/gentoo
deleted file mode 100644
index 30a1eb1..0000000
--- a/completions/gentoo
+++ /dev/null
@@ -1,1652 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-source "@helpersdir@/gentoo-common.sh"
-
-#
-# emerge completion command
-#
-_emerge()
-{
-    local c cur prev curword numwords opts cond prepend
-    local words stophere i x
-    local action actionpos sysactions pkgpos
-    local portdir=$(_portdir -o)
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    opts=''
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-        COMPREPLY=($(compgen -f -- ${cur}))
-        return 0
-    fi
-
-    # find action
-    for x in ${COMP_LINE} ; do
-        if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
-            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
-        then
-            action=${x}
-            break
-        fi
-    done
-
-    if [[ -n ${action} ]]; then
-        for ((i = 0; i < ${numwords}; i++ )); do
-            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
-                actionpos=${i}
-                pkgpos=$((actionpos + 1))
-                break
-            fi
-        done
-
-        if [[ ${action} == -* && ${action} != --* ]] ; then
-            case "${action}" in
-            -*C*) action='--unmerge' ;;
-            -*P*) action='--prune' ;;
-            -*c*) action='--clean' ;;
-            -*s*) action='--search' ;;
-            esac
-        fi
-    else
-        for ((i = 1; i < ${numwords}; i++ )); do
-            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
-                pkgpos=${i}
-                break
-            fi
-        done
-        [[ -z ${pkgpos} ]] && pkgpos=${numwords}
-    fi
-
-    # Handle special cases.
-    if [[ ${action} == "--search" ]] || [[ ${COMP_LINE} == *" "-@(S|-searchdesc)* ]] || \
-        [[ ${COMP_LINE} == *" "-@(V|-version)* ]] || [[ ${action} == "--metadata" ]]
-    then
-        unset COMPREPLY
-        return 0
-    elif [[ ${COMP_LINE} == *" "-@(h|-help)* ]] ; then
-        unset COMPREPLY
-        [[ ${curword} -eq 2 ]] && COMPREPLY=($(compgen -W 'system world --sync' -- ${cur}))
-        return 0
-    fi
-
-    # Complete on options.
-    if [[ ${cur} == -* ]]; then
-        # If a resume option was specified, it needs special handling.
-        if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
-            if [[ ${cur} == --* ]]; then
-                opts="--ask --pretend --resume --skipfirst"
-            elif [[ ${cur} == -* ]]; then
-                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
-            fi
-        elif [[ ${cur} == --* ]]; then
-            # Complete on long options.
-            opts="--alphabetical --ask \
-                --buildpkg --buildpkgonly \
-                --changelog --clean --color=y --color=n --columns --complete-graph --config \
-                --debug --deep --depclean \
-                --emptytree \
-                --fetch-all-uri --fetchonly \
-                --getbinpkg --getbinpkgonly \
-                --ignore-default-opts --info \
-                --jobs= \
-                --keep-going \
-                --metadata \
-                --newuse --noconfmem --nodeps --noreplace --nospinner \
-                --oneshot --onlydeps \
-                --pretend --prune \
-                --quiet \
-                --reinstall=changed-use --regen \
-                --search \
-                --sync \
-                --tree \
-                --unmerge --update --upgradeonly --usepkg --usepkgonly \
-                --verbose \
-                --with-bdeps=y --with-bdeps=n"
-            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} --help --resume --searchdesc --version"
-            fi
-        elif [[ ${cur} == -* ]]; then
-            # Complete on short options.
-            opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
-            if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} -h -S -V"
-            fi
-            if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
-                opts="${opts} -C -P -c -s"
-            fi
-        fi
-
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-
-        # NOTE: This slows things down!
-        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
-        # This removes any options from the list of completions that have
-        # already been specified on the command line.
-        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
-            (while read -d ' ' i; do
-                [[ -z ${i} ]] && continue
-                # flatten array with spaces on either side,
-                # otherwise we cannot grep on word boundaries of
-                # first and last word
-                COMPREPLY=" ${COMPREPLY[@]} "
-                # remove word from list of completions
-                COMPREPLY=(${COMPREPLY/ ${i%% *} / })
-            done
-            echo ${COMPREPLY[@]})))
-
-        return 0
-    fi # options
-
-    # Stop completion if a special case is encountered.
-    if [[ ${action} =~ (system|world) ]] || \
-        [[ ${COMP_LINE} =~ --(depclean|metadata|regen|resume|skipfirst|sync) ]]
-    then
-        unset COMPREPLY
-        return 0
-    fi
-
-    # Complete on installed packages when unmerging.
-    if [[ "${action}" == '--unmerge' ]]; then
-    if [[ -n "${cur}" ]] ; then
-        if [[ "${cur}" == */* ]]; then
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
-        else
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
-
-                local n=0
-                for i in ${words} ; do
-                    [[ ${i} == ${cur}* ]] && n=$((n+1))
-                done
-
-                if [[ ${n} -eq 1 ]] ; then
-                    words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
-                fi
-        fi
-            COMPREPLY=($(for i in ${words} ; do \
-                            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-                        done))
-    else
-        COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
-    fi
-
-        [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
-        return 0
-    fi
-
-    # Check for conditional.
-    cond="${cur%%[A-Za-z0-9]*}"
-    cur="${cur:${#cond}}"
-    if [[ ${cond:0:1} == "'" || ${cond:0:1} == '"' ]] ; then
-        prepend="-P ${cond:1}"
-        c="${cond:1}"
-    else
-        c="${cond}"
-    fi
-
-    # Handle cases where a conditional is specified.
-    if [[ -n "${cond}" ]]; then
-    if [[ -n "${cur}" ]]; then
-            if [[ ${cur} == */* ]]; then
-                if [[ ${cur} == *-[0-9]* ]] ; then
-                    words="$(\
-                        for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            local cat="${cur%/*}" ; \
-                            local pkg="$(echo ${cur%-[0-9]*})" ; \
-                            pkg="${pkg##*/}" ; \
-                            for x in ${cat}/${pkg}/*.ebuild ; do \
-                                [[ -f ${x} ]] || continue ; \
-                                x="${x/${pkg}\/}" ; \
-                                echo "${x%*.ebuild}" ; \
-                            done ; \
-                        done)"
-                else
-            words="$(\
-                    for pd in ${portdir} ; do \
-                        builtin cd ${pd}; \
-                        compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
-                    done)"
-                fi
-
-                local w
-                for x in $words ; do
-                    w="${x}\n${w}"
-                done
-
-                words=$(echo -ne ${w} | sort | uniq)
-                COMPREPLY=( ${words} )
-
-                # Complete on the specific versions (if appropriate).
-                # TODO - see if we can use _pkgname
-                if [[ ${#COMPREPLY[@]} -le 1 ]]; then
-                    COMPREPLY=($(
-                        for pd in ${portdir}; do
-                            if [[ -d ${pd}/metadata/md5-cache ]]; then
-                                builtin cd ${pd}/metadata/md5-cache
-                                compgen ${prepend} -G "${cur}*" -- "${cur}"
-                            elif [[ -d ${pd}/metadata/cache ]]; then
-                                builtin cd ${pd}/metadata/cache
-                                compgen ${prepend} -G "${cur}*" -- "${cur}"
-                            else
-                                builtin cd ${pd}
-                                local cat="${cur%/*}"
-                                local pkg="$(echo ${cur%-[0-9]*}*)"
-                                pkg="${pkg##*/}"
-                                for x in ${cat}/${pkg}/*.ebuild; do
-                                    [[ -f "${x}" ]] || continue
-                                    x="${x/${pkg}\/}"
-                                    if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
-                                        echo "${c}${x%*.ebuild}"
-                                    else
-                                        echo "${x%*.ebuild}"
-                                    fi
-                                done
-                            fi
-                        done
-                    ))
-                else
-                    COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
-                fi
-            else
-                words="$(\
-                    for pd in ${portdir} ; do \
-                        builtin cd ${pd} ; \
-                        compgen ${prepend} -S '/' -G "${cur}*" -- "${cur}" ; \
-                    done)"
-
-                local w
-                for x in words ; do
-                    w="${x}\n${w}"
-                done
-
-                COMPREPLY=($(echo -e ${w} | uniq))
-                [[ ${#COMPREPLY[@]} = 1 ]] && \
-                    COMPREPLY=($(\
-                        for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            compgen ${prepend} -G "${cur}*/*" -- "${cur}" ; \
-                        done))
-            fi
-        else
-        words="$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    compgen -G "*-*"; \
-                done)"
-        COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
-    fi
-
-        # If all else fails, try to complete on package names without the
-    # category being specified.
-    if [[ -z "${COMPREPLY}" ]]; then
-        words="$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    for i in *-*/${cur}*; do \
-                        [[ -d $i ]] && echo ${i##*/}; \
-                    done ; \
-                done)"
-
-        COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
-
-        if [[ ${#COMPREPLY[@]} -le 1 ]]; then
-            # Now complete on the specific versions.
-            words="$(
-                for pd in ${portdir}; do
-                    if [[ -d ${pd}/metadata/md5-cache ]]; then
-                        builtin cd ${pd}/metadata/md5-cache
-                        for i in */${cur}*; do
-                            [[ -f $i ]] && echo ${i##*/}
-                        done
-                    elif [[ -d ${pd}/metadata/cache ]]; then
-                        builtin cd ${pd}/metadata/cache
-                        for i in */${cur}*; do
-                            [[ -f $i ]] && echo ${i##*/}
-                        done
-                    fi
-                done
-            )"
-            COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
-        fi
-    fi
-    return 0
-    fi
-
-    # Complete on packages.
-    #
-    # Only allow these actions if no packages have been specified.
-    #
-    # TODO: This doesn't block these actions if no categories are
-    #       specified. Please fix me.
-    #
-    #       e.g. emerge -a gentoo-dev-sources
-    #
-    #            will still allow system and world actions to be specified,
-    #            as opposed to
-    #
-    #            emerge -a sys-kernel/gentoo-dev-sources
-    #
-    if [[ ${COMP_CWORD} -eq 1 ]] || [[ ! " ${COMP_LINE} " == *" "*[/]*" "* ]] ; then
-        sysactions=$'\n'"system"$'\n'"world"
-    else
-        sysactions=''
-    fi
-
-    if [[ -n "${cur}" ]] ; then
-        if [[ ${cur} == */* ]] ; then
-            words=$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd}; \
-                    compgen -X "*metadata.xml" -G "${cur}*" ; \
-                done)"${sysactions}"
-        else
-            local ww=$(\
-                for pd in ${portdir} ; do \
-                    builtin cd ${pd} ; \
-                    compgen -X "!@(*-*|virtual)" -S '/' -G "${cur}*"; \
-                done)"${sysactions}"
-            # complete on virtuals
-            ww="${ww} $(\
-                for pd in ${portdir} ; do \
-                    if [[ -d ${pd}/profiles ]] ; then
-                        find ${pd}/profiles -name virtuals -exec \
-                            sed -n -e 's|^\(virtual/[[:alnum:]]\+\).*$|\1|p' {} \; | \
-                            sort -u
-                    fi ; \
-                done)"
-
-            local w
-            for x in ${ww} ; do w="${x}\n${w}" ; done
-
-            words=$(echo -e ${w} | sort -u)
-
-            local n=0
-            for i in ${words} ; do
-                [[ ${i} == ${cur}* ]] && n=$((n+1))
-            done
-
-            if [[ ${n} -eq 1 ]] ; then
-                words=$(for pd in ${portdir} ; do \
-                            builtin cd ${pd} ; \
-                            compgen -G "*-*/*" ; \
-                        done)"${sysactions}"
-            fi
-        fi
-        COMPREPLY=($(for i in ${words} ; do \
-                        [[ ${i} == ${cur}* ]] && echo ${i} ; \
-                    done))
-    else
-        words="$(\
-            for pd in ${portdir} ; do \
-                builtin cd ${pd} ; \
-                compgen -S '/' -G "*-*" ; \
-            done)""${sysactions}"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
-    fi
-
-    # If all else fails, try to complete on package names without the
-    # category being specified.
-    if [[ -z "${COMPREPLY}" ]]; then
-        words="$(\
-            for pd in ${portdir} ; do \
-                builtin cd ${pd}; \
-                for i in [a-z]*-[a-z0-9]*/${cur}*; do \
-                    [[ -d $i ]] && echo ${i##*/}; \
-                done ; \
-            done)"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
-    fi
-
-    return 0
-} &&
-complete -o filenames -F _emerge emerge
-
-#
-# ebuild completion command
-#
-_ebuild()
-{
-    local cur opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-
-    opts="help setup clean fetch digest manifest unpack compile test preinst \
-        install postinst qmerge merge unmerge prerm postrm config package rpm \
-        configure prepare"
-
-    if [[ $COMP_CWORD -eq 1 ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
-            $(compgen -d -- ${cur}) \
-            $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
-
-    elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
-
-    elif [[ $COMP_CWORD -ge 2 ]] ; then
-    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-    fi
-    return 0
-} &&
-complete -o filenames -F _ebuild ebuild
-
-#
-# rc completion command
-#
-_rc()
-{
-    local cur
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
-    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    fi
-    return 0
-} &&
-complete -F _rc rc
-
-#
-# rc-status completion command
-#
-_rcstatus()
-{
-    local cur
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-        if [[ "${cur}" == --* ]]; then
-        COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
-    elif [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
-    fi
-    else
-    unset COMPREPLY
-    fi
-    return 0
-} &&
-complete -F _rcstatus rc-status
-
-#
-# rc-update completion command
-#
-_rcupdate()
-{
-    local cur show
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-    if [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W 'add del show' ${cur}))
-    fi
-    else
-        if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
-        show="TRUE"
-    fi
-    if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
-            ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
-        then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    elif [[ $COMP_CWORD -eq 2 ]]; then
-        COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
-    elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    else
-        unset COMPREPLY
-    fi
-    fi
-    return 0
-} &&
-complete -F _rcupdate rc-update
-
-#
-# gcc-config completion command
-#
-_gcc_config() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-O --use-old \
-        -P --use-portage-chost \
-        -c --get-current-profile \
-        -l --list-profiles \
-        -E --print-environ \
-        -B --get-bin-path \
-        -L --get-lib-path \
-        -X --get-stdcxx-incdir"
-
-    if [[ "${cur}" == -* ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        return 0
-    elif [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
-            $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
-                -- ${cur}) )
-        return 0
-    fi
-
-    case "${prev}" in
-        -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
-            COMPREPLY=()
-            ;;
-        *)
-            COMPREPLY=( $(compgen -W "\
-                $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
-            ;;
-    esac
-} &&
-complete -F _gcc_config gcc-config
-
-#
-# distcc-config completion command
-#
-_distccconfig()
-{
-    local cur curword numwords opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    if [[ ${numwords} -gt 3 ]]; then
-    unset COMPREPLY
-    return 0
-    fi
-    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
-    if [[ ${numwords} -le 2 ]] && [[ ${curword} -eq 1 ]]; then
-        opts="--get-hosts \
-        --get-verbose \
-        --get-log \
-        --set-hosts \
-        --set-verbose \
-        --set-log \
-        --add-path \
-        --no-path"
-    else
-        opts=""
-    fi
-    else
-    opts=""
-    fi
-    COMPREPLY=($(compgen -W "${opts}" | grep ^$cur))
-    return 0
-} &&
-complete -F _distccconfig distcc-config
-
-#
-# java-config completion command
-#
-_javaconfig()
-{
-    local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
-    local multiplepkgs pkgs execopts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    opts=""
-    args=""
-    pkgs=""
-    sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
-    vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
-    grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
-    multiplepkgs=""
-    execopts="HtmlConverter JavaPluginControlPanel \
-    appletviewer awt_robot \
-    extcheck \
-    idlj \
-    j2sdk-config jar jarsigner \
-    java java-rmi.cgi java_vm javac javadoc javah javap jdb \
-    keytool kinit klist ktab \
-    native2ascii \
-    oldjava oldjavac oldjdb orbd \
-    policytool \
-    realpath rmic rmid rmiregistry \
-    serialver servertool \
-        tnameserv"
-    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
-    case "${cur}" in
-        --java)
-        opts="--java --javac --java-version"
-        ;;
-        --j@(a@(r|va@(c|-version))|@(dk|re)-home))
-        opts=""
-        ;;
-        --list-available-@(packages|vms))
-        opts=""
-        ;;
-        --@(exec|set-@(user|system)-@(classpath|vm)))
-        opts="${cur}="
-        ;;
-        --set-@(user|system)-@(classpath|vm)=)
-        if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
-            flag="--list-available-vms"
-            args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
-        else
-            flag="--list-available-packages"
-            args=$(java-config --nocolor "${flag}" | ${sedcmd})
-        fi
-        for arg in ${args}; do
-            [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-        done
-        COMPREPLY=($(compgen $nospace -W "${opts}"))
-        return 0
-        ;;
-        --exec=)
-        COMPREPLY=($(compgen $nospace -W "${execopts}"))
-        return 0
-        ;;
-        *)
-            if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
-            args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
-            if [[ "${cur}" == "--set-system-vm="* ]]; then
-            spec=${cur##--set-system-vm=}
-            else
-            spec=${cur##--set-user-vm=}
-            fi
-            for arg in ${args}; do
-            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-            fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
-            args=$(java-config --nocolor --list-available-packages | ${sedcmd})
-            [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
-            if [[ "${cur}" == "--set-system-classpath="* ]]; then
-            spec="${cur##--set-system-classpath=}"
-            else
-            spec="${cur##--set-user-classpath=}"
-            fi
-            if [[ -n "${multiplepkgs}" ]]; then
-            pkgs="${spec%,*}"
-            spec="${spec##*,}"
-            fi
-            if [[ -n "${multiplepkgs}" ]]; then
-                for arg in ${args}; do
-                if [[ "${spec}" ]]; then
-                    if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
-                        && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
-                                then
-                    [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
-                    fi
-                else
-                    if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
-                        [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
-                    fi
-                fi
-                done
-            [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
-            else
-                for arg in ${args}; do
-                if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-                fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            fi
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        elif [[ "${cur}" == "--exec="* ]]; then
-            spec=${cur##--exec=}
-            for arg in ${execopts}; do
-            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
-                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
-            fi
-            done
-            [[ "${opts}" == "${spec}" ]] && opts=""
-            COMPREPLY=($(compgen -W "${opts}"))
-            return 0
-        else
-            opts="--classpath --clean-system-classpath --clean-user-classpath \
-                --exec \
-            --full-classpath \
-                --jar --java --javac --java-version --jdk-home --jre-home \
-                --list-available-packages --list-available-vms \
-            --nocolor \
-            --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
-            [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
-        fi
-            ;;
-        esac
-    elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
-    opts="--classpath --clean-system-classpath --clean-user-classpath \
-        --exec \
-        --full-classpath \
-        --jar --java --javac --java-version --jdk-home --jre-home \
-        --list-available-packages --list-available-vms \
-        --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
-    fi
-    COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
-    return 0
-} &&
-complete $nospace -F _javaconfig java-config
-
-#
-# browser-config completion command
-#
-_browserconfig()
-{
-    local cur prev
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    if [[ ${COMP_CWORD} -eq 1 ]]; then
-    COMPREPLY=($(compgen -W '-b -h -m' -- ${cur}))
-    elif [[ "${prev}" == "-b" ]]; then
-    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/usr/share/browser-config/*; do [ -f $i ] && echo ${i##*/}; done)" $cur))
-    elif [[ "${prev}" == "-m" ]]; then
-        COMPREPLY=($(compgen -W "same_window new_window new_tab new_browser" -- ${cur}))
-    if [[ -z "${COMPREPLY}" ]]; then
-        COMPREPLY=''
-    fi
-    else
-    unset COMPREPLY
-    fi
-    return 0
-} &&
-complete -F _browserconfig browser-config
-
-#
-# Bash completion for the Gentoo 'equery' command
-#
-_equery()
-{
-    local cur prev mode portdir i j
-    portdir=$(_portdir)
-    mode="GLOBAL"
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    # Find out what we're currently doing here.
-    j=0
-    for i in "${COMP_WORDS[@]}"; do
-        if [[ $j -lt $COMP_CWORD ]]; then
-        j=$((j + 1))
-        case $i in
-            @(belongs|ch@(anges|eck)|dep@(ends|graph)|files|has?(use)|keywords|list|meta|size|uses|which|b|c|k|d|g|f|a|h|y|l|m|s|u|w))
-            mode=$i
-            ;;
-        esac
-    fi
-    done
-    # Now get to work.
-    case $mode in
-    GLOBAL)
-        # Complete commands and global options.
-        case $cur in
-        -*)
-            COMPREPLY=($(compgen -W "-q --quiet -C --nocolor -h --help -V --version" -- $cur))
-            ;;
-        *)
-            COMPREPLY=($(compgen -W "belongs changes check depends depgraph files has hasuse keywords list meta size uses which" -- $cur))
-            ;;
-        esac
-        ;;
-    c?(hanges))
-        # Complete package name only if it is not yet supplied.
-        if [[ ${prev} == ${mode} ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help" -- $cur))
-                ;;
-                *)
-                    _pkgname -A $cur
-                ;;
-            esac
-        else
-            case $cur in
-                *)
-                    COMPREPLY=($(compgen -W "-h --help -l --latest -f --full --limit --from --to" -- $cur))
-                ;;
-            esac
-        fi
-        ;;
-    f?(iles))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            # --filter=<list>: completion of the files types list
-            if [[ ${prev} == "-f" || "${cur}" == "--filter="* ]] ; then
-                COMPREPLY=($(_list_compgen "${cur#--filter=}" , \
-                    dir,obj,sym,dev,fifo,path,conf,cmd,doc,man,info))
-                return 0
-            fi
-        case $cur in
-            --f*)
-            # don't handle --filter= with others to avoid space after the "="
-            COMPREPLY=($(compgen -P "--filter=" \
-                -W "dir obj sym dev fifo path conf cmd doc man info"))
-            ;;
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -m --md5sum -s --timestamp -t
-                --type --tree -f --filter=" -- $cur))
-            ;;
-            *)
-            # Only installed packages can have their files listed.
-                _pkgname -I $cur
-            ;;
-        esac
-        fi
-        ;;
-    a|has)
-        COMPREPLY=($(compgen -W "-h --help -I --exclude-installed -o \
-             --overlay-tree -p --portage-tree -F --format" -- $cur))
-        ;;
-    y|keywords)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case "${cur}" in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -v --version -a --arch -A
-                    --align -T --top-position -B --bold -C --color -O --overlays
-                    -P --prefix -S --ignore-slot" -- $cur))
-                    ;;
-                *)
-                    _pkgname -A $cur
-                    ;;
-            esac
-        fi
-        ;;
-    l?(ist))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case "${cur}" in
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -d --duplicates -b
-                --binpkgs-missing -f --full-regex -m --mask-reason -I
-                --exclude-installed -o --overlay-tree -p --portage-tree -F
-                --format" -- $cur))
-            ;;
-            *)
-                if [[ ${COMP_WORDS[@]} =~ -(p|o) || ${COMP_WORDS[@]} =~ --(portage|overlay)-tree ]]; then
-                    _pkgname -A $cur
-                else
-                    _pkgname -I $cur
-                fi
-            ;;
-        esac
-        fi
-        ;;
-    b?(elongs))
-        # Only complete if the previous entry on the command line is not
-        # a file name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -f --full-regex -e
-                        --early-out -n --name-only" -- $cur))
-                    ;;
-                *)
-                    COMPREPLY=($(compgen -f -- $cur) \
-                        $(compgen -d -S '/' -- $cur))
-                    ;;
-            esac
-        fi
-        ;;
-    u?(ses))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -a --all" -- $cur))
-                ;;
-                *)
-                    # Complete on all package names.
-                    _pkgname -A $cur
-                ;;
-            esac
-        fi
-        ;;
-    w?(hich))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "-h --help -m --include-masked" -- $cur))
-                ;;
-                *)
-                    # Complete on all package names.
-                    _pkgname -A $cur
-                ;;
-            esac
-        fi
-        ;;
-    g|depgraph)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-            -*)
-                COMPREPLY=($(compgen -W "-h --help -A --no-atom -M --no-mask -U
-                    --no-useflags -l --linear --depth" -- $cur))
-            ;;
-            *)
-            # Complete on all package names.
-            _pkgname -A $cur
-            ;;
-        esac
-        fi
-        ;;
-    d?(epends))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case $cur in
-            -*)
-                COMPREPLY=($(compgen -W "-h --help -a --all-packages -D
-                    --indirect --depth" -- $cur))
-            ;;
-            *)
-            case $prev in
-                -a|--all-packages)
-                # Complete on all package names.
-                _pkgname -A $cur
-                ;;
-                *)
-                # Complete on installed package names.
-                    _pkgname -I $cur
-                ;;
-                        esac
-                        ;;
-        esac
-        fi
-        ;;
-    m?(eta))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            _equery_meta $cur
-        fi
-        ;;
-    k|check)
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} ]]; then
-            case $cur in
-                -*)
-                    COMPREPLY=($(compgen -W "${COMPREPLY[@]} -h --help -f
-                        --full-regex -o --only-failures" -- ${cur}))
-                ;;
-                *)
-                # Only installed packages can have their integrity verified.
-                    _pkgname -I $cur
-                ;;
-            esac
-        fi
-        ;;
-    s?(ize))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-        case $cur in
-            -*)
-            COMPREPLY=($(compgen -W "-h --help -b --bytes -f
-                --full-regex" -- $cur))
-            ;;
-            *)
-            # Only installed packages can have their size calculated.
-            _pkgname -I $cur
-            ;;
-        esac
-        fi
-        ;;
-        h?(asuse))
-        # Only complete if the previous entry on the command line is not
-        # a package name.
-        if [[ ${prev} == ${mode} || ${prev:0:1} == "-" ]]; then
-            case $cur in
-                -*)
-                COMPREPLY=($(compgen -W "--help -i --installed -I --exclude-installed -p --portage-tree -o --overlay" -- $cur))
-                ;;
-                *)
-                local glob loc
-                        [[ -f ${portdir}/profiles/use.desc ]] || return 0
-                        [[ -f ${portdir}/profiles/use.local.desc ]] || return 0
-                glob=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
-                loc=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
-                COMPREPLY=($(compgen -W "$glob $loc" -- $cur))
-                ;;
-            esac
-            fi
-            ;;
-    esac
-    return 0
-} &&
-complete -F _equery equery
-
-#
-# epkginfo completion
-#
-
-_epkginfo()
-{
-    local cur prev
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    # Only complete if the previous entry on the command line is not
-    # a package name.
-    if [[ ${COMP_CWORD} -eq 1 || ${prev:0:1} == "-" ]]; then
-        _equery_meta $cur
-    fi
-
-    return 0
-} &&
-complete -F _epkginfo epkginfo
-
-#
-# ekeyword completion
-#
-
-_ekeyword()
-{
-    local cur portdir archl_s archl_u archl_r archl_m arch
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    portdir=$(_portdir)
-
-    [[ -f ${portdir}/profiles/arch.list ]] || return 0
-
-    for arch in all $(< ${portdir}/profiles/arch.list) ; do
-        archl_m="${archl_m} -${arch}"
-        archl_u="${archl_u} ~${arch}"
-        archl_r="${archl_r} ^${arch}"
-        archl_s="${archl_s}  ${arch}"
-    done
-
-    case ${cur} in
-        -*)
-            COMPREPLY=($(compgen -W "${archl_m}" -- ${cur}))
-            ;;
-        ~*)
-            COMPREPLY=($(compgen -W "${archl_u}" -- ${cur}))
-            ;;
-        ^*)
-            COMPREPLY=($(compgen -W "${archl_r}" -- ${cur}))
-            ;;
-        *)
-            COMPREPLY=($(compgen -W "${archl_s}" -- ${cur}))
-            _filedir 'ebuild'
-            ;;
-        esac
-} &&
-complete -o filenames -F _ekeyword ekeyword
-
-#
-# portageq completion
-#
-
-_portageq() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    opts="config_protect_mask \
-      config_protect \
-      vdb_path \
-      gentoo_mirrors \
-      all_best_visible \
-      match \
-      best_visible \
-      mass_best_visible \
-      has_version \
-      portdir \
-      envvar \
-      mass_best_version \
-      best_version \
-      pkgdir \
-      portdir_overlay \
-      distdir"
-
-    if [[ $COMP_CWORD -eq 1 ]] ; then
-    # would always be correct, but it's pretty slow...
-    #COMPREPLY=($(compgen -W "$(portageq | grep '^   [[:lower:]]' | \
-    #    sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
-    #    -- ${cur}))
-    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-    fi
-
-    case "${prev}" in
-    config*|vdb_path|gentoo_mirrors|*dir*)
-        COMPREPLY=()
-        ;;
-
-    # this also isn't the fastest, but I welcome an alternative method
-    envvar)
-        COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
-                sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
-        ;;
-
-    *v@(isible|ersion)|match)
-        COMPREPLY=($(compgen $nospace -W '/' -- $cur))
-        ;;
-
-    # $prev is a path, so complete on category/package
-    */*)
-            local x a=0
-            for x in ${COMP_WORDS[@]} ; do
-                # This is the only one
-                if [[ "${x}" == "all_best_visible" ]] ; then
-                    a=1
-                    break
-                fi
-            done
-
-            if [[ ${a} -eq 1 ]] ; then
-                COMPREPLY=()
-            else
-                # Check for conditional.
-#                cond="${cur%%[A-Za-z0-9]*}"
-#                cur="${cur:${#cond}}"
-
-#                if [[ -n "${cond}" ]] ; then
-#                    _pkgname -A $cur
-#                else
-                    _pkgname -A $cur
-#                fi
-            fi
-        ;;
-    esac
-} &&
-complete -F _portageq portageq
-
-#
-# webapp-config completion
-#
-
-_webapp_complete_appver()
-{
-    local x proot ibase cur="$2"
-    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-        echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
-        echo ibase="${WA_INSTALLSBASE:-installs}")
-
-    case "$1" in
-    # complete on installed
-    installed)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/*/*/installs ; do \
-            if [[ -f "${x}" ]] ; then \
-            local y="${x%/*}" ; \
-            y="${y%/*}" ; \
-            echo "${y##*/}" ; \
-            fi ; \
-        done)" -- ${cur}))
-        ;;
-
-    # complete on uninstalled
-    uninstalled)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/*/* ; do \
-            if [[ ! -f "${x}/${ibase}" ]] ; then \
-            local y="${x%/*}" ; \
-            echo "${y##*/}" ; \
-            fi ; \
-        done)" -- ${cur}))
-        ;;
-
-    # all
-    all)
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/* ; do \
-            [[ -d "${x}" ]] && echo "${x##*/}" ; \
-        done)" -- ${cur}))
-        ;;
-
-    # complete on version
-    *)
-        [[ -d "${proot}/$1" ]] || return 1
-        COMPREPLY=($(compgen -W "$(\
-        for x in ${proot}/$1/* ; do \
-            [[ -d "${x}" ]] && echo "${x##*/}" ; \
-        done)" -- ${cur}))
-        ;;
-    esac
-}
-
-_webapp_config()
-{
-    local cur prev actions opts hostroot
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-
-    actions="-I --install -U --upgrade -C --clean --list-installs \
-    --list-unused-installs --show-installed --show-postinst \
-    --help -v --version"
-    opts="--bug-report --pretend -p -u --user -g --group \
-    -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
-    --virtual-files --force-virtual"
-
-    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-    echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
-
-    # --bug-report, --pretend, and -p can only be used as first arg
-    if [[ ${COMP_CWORD} -gt 1 ]] ; then
-        opts="${opts/--bug-report --pretend -p}"
-    fi
-
-    if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        --bug-report|-p|--pretend)
-        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
-        ;;
-
-        -I|--install)
-            _webapp_complete_appver all ${cur}
-            ;;
-
-        -U|--upgrade)
-            _webapp_complete_appver installed ${cur}
-            ;;
-
-        # only complete on -d since it is required if -C is specified
-        -C|--clean)
-            COMPREPLY=($(compgen -W "-d" -- ${cur}))
-            ;;
-
-        --list-unused-installs)
-            _webapp_complete_appver uninstalled ${cur}
-            ;;
-
-        --list-installs|--show-postinst)
-            _webapp_complete_appver all ${cur}
-            ;;
-
-        #  hrm... anyone know a better way to reliably do this?
-        -h|--host)
-            local x
-            COMPREPLY=($(compgen -W "$(\
-                for x in ${hostroot}/* ; do \
-                    [[ -d "${x}" ]] && echo "${x##*/}" ; \
-                done)" -- ${cur}))
-            ;;
-
-        --virtual*)
-            COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
-            -- ${cur}))
-            ;;
-
-        -d|--dir)
-        local host x i=0
-                # see if --host has been specified, and if so, get the value
-                # that was passed to it.
-        for x in ${COMP_WORDS[@]} ; do
-            if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
-            host="${COMP_WORDS[((i+1))]}"
-            break
-            fi
-            i=$((i+1))
-        done
-
-                # otherwise, use the default host
-        if [[ "${host}" == "" ]] ; then
-            eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
-            echo host="${VHOST_HOSTNAME:-localhost}")
-        fi
-
-            COMPREPLY=($(compgen -W "$(\
-            for x in ${hostroot}${host}/* ; do \
-            [[ -d "${x}" ]] && echo "${x}" ; \
-            done)" -- ${cur}))
-            ;;
-        -u|--user)
-            COMPREPLY=($(compgen -u -- ${cur}))
-            ;;
-        -g|--group)
-            COMPREPLY=($(compgen -g -- ${cur}))
-            ;;
-
-        # we haven't recognized it yet, so more than likely ${prev}
-        # is a 'app-name' ; assuming it is indeed a valid 'app-name'
-        # (_webapp_complete_appver does the check), complete on available
-        # 'app-version's
-        *)
-            _webapp_complete_appver ${prev} ${cur} || \
-                    _webapp_complete_appver all ${cur}
-            ;;
-    esac
-} &&
-complete -F _webapp_config webapp-config
-
-_revdep_rebuild() {
-    local cur prev numwords opts
-    local words i x
-    local action actionpos
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-            COMPREPLY=($(compgen -f -- ${cur}))
-            return 0
-        fi
-
-    # find action
-    for ((i = 0; i < ${numwords}; i++ )); do
-        case ${COMP_WORDS[${i}]} in
-            --library|-L)
-                action=${COMP_WORDS[${i}]}
-                actionpos=${i}
-                ;;
-            --help|-h)
-                action=${COMP_WORDS[${i}]}
-                actionpos=${i}
-                ;;
-        esac
-    done
-
-    if [[ ${cur} == -* ]]; then
-        if [[ ${cur} == --* ]]; then
-            opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        else
-            opts="-e -h -i -k -L -l -o -p -P -q -u -v"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-        fi
-        return 0
-    fi
-    if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
-        if [[ "${cur}" == */* ]]; then
-            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
-        else
-            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
-        fi
-    fi
-    return 0
-} &&
-complete -F _revdep_rebuild revdep-rebuild
-
-_splat() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
-    --list -u --count -p --package -t --sort -r --reverse"
-
-    if [[ ${cur} == -* ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        -f|--logfile)
-            COMPREPLY=($(compgen -f -- ${cur}))
-            ;;
-        *)
-            _pkgname -A ${cur}
-            COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
-            ;;
-    esac
-} &&
-complete -o filenames -F _splat splat
-
-_euse() {
-    local cur prev opts sopts use portdir
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-h --help -v --version -i --info -I --info-installed -a --active
-        -E --enable -D --disable -P --prune"
-    sopts="-g --global -l --local"
-
-    if [[ ${cur} == -* ]] && [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        -h|--help|-v|--version)
-            COMPREPLY=()
-            ;;
-        -a|--active)
-            COMPREPLY=($(compgen -W "${sopts}" -- ${cur}))
-            ;;
-        -i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)
-            portdir=$(_portdir)
-        use="$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc) \
-        $(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)"
-        COMPREPLY=($(compgen -W "${use} ${sopts}" -- ${cur}))
-            ;;
-        *)
-            local l=0 g=0
-
-            if [[ ${COMP_LINE} == *" "@(-l|--local)* ]] ; then
-                l=1
-            elif [[ ${COMP_LINE} == *" "@(-g|--global)* ]] ; then
-                g=1
-            fi
-
-            if [[ ${COMP_LINE} == *" "@(-i|--info|-I|--info-installed|-E|--enable|-D|--disable|-P|--prune)* ]]
-            then
-                portdir=$(_portdir)
-
-                if [[ ${l} -eq 1 ]] ; then
-                    use=$(sed -n -e 's/^[^ ]\+:\([^ ]*\) - .*$/\1/p' ${portdir}/profiles/use.local.desc)
-                elif [[ ${g} -eq 1 ]] ; then
-                    use=$(sed -n -e 's/^\([^ ]\+\) - .*$/\1/p' ${portdir}/profiles/use.desc)
-                fi
-
-                COMPREPLY=($(compgen -W "${use}" -- ${cur}))
-            fi
-    esac
-} &&
-complete -F _euse euse
-
-_glsa_check() {
-    local cur opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
-    --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
-    -c --cve -m --mail"
-
-    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    # too slow otherwise
-    if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
-        [[ $(stat ${ROOT}/tmp/gc.out | \
-        sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
-    then
-        glsa-check -nl 2>/dev/null | \
-            sed -n -e  's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
-                ${ROOT}/tmp/gc.out
-    fi
-
-    COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
-} &&
-complete -F _glsa_check glsa-check
-
-_epm() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD]}"
-    opts="-q --query -V -y --verify -e --erase --help"
-
-    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
-        return 0
-    fi
-
-    case "${prev}" in
-        --help)
-            COMPREPLY=()
-            ;;
-        -q|--query)
-            _pkgname -I ${cur}
-            COMPREPLY=($(compgen -W "${COMPREPLY[@]} -l -f -G -a" -- ${cur}))
-            ;;
-        *)
-            local x all=0 file=0
-            for x in ${COMP_WORDS[@]} ; do
-                [[ ${x} == -* ]] || continue
-                [[ ${x} == *f* ]] && file=1
-                [[ ${x} == *a* ]] && all=1
-            done
-
-            if [[ ${file} -eq 1 ]] ; then
-                COMPREPLY=($(compgen -f -- ${cur}))
-            elif [[ ${all} -eq 1 ]] ; then
-                COMPREPLY=()
-            else
-                _pkgname -I ${cur}
-            fi
-            ;;
-    esac
-} &&
-complete -o filenames -F _epm epm
-
-_metagen() {
-    local cur prev opts
-    COMPREPLY=()
-    _get_comp_words_by_ref cur prev
-    opts="$(_parse_help ${COMP_WORDS[0]})"
-
-    case $prev in
-        -h|--help|--version)
-            return 0
-            ;;
-        -H|-e|-n|-d|-l)
-            return 0
-            ;;
-        -o)
-            _filedir
-            return 0
-            ;;
-    esac
-
-    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-    return 0
-} &&
-complete -F _metagen metagen
-
-_rc_service() {
-    local cur prev numwords opts
-    local words i x filename
-    local action actionpos
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-            COMPREPLY=($(compgen -f -- ${cur}))
-            return 0
-        fi
-
-    # find action
-    for x in ${COMP_LINE} ; do
-        if [[ ${x} =~ --(list|exists|resolve) ]] || \
-            [[ ${x} =~ -(l|e|r) ]]
-        then
-            action=${x}
-            break
-        fi
-    done
-    if [[ -n ${action} ]]; then
-        for ((i = 0; i < ${numwords}; i++ )); do
-            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
-                actionpos=${i}
-                break
-            fi
-        done
-
-        for ((i = 1; i < ${numwords}; i++ )); do
-            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
-                break
-            fi
-        done
-    fi
-
-    if [[ ${COMP_CWORD} -eq 3 ]]; then
-        return 1
-    fi
-
-    # check if an option was typed
-    if [[ ${cur} == -* ]]; then
-        if [[ ${cur} == --* ]]; then
-            opts="--list --exists --resolve"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        elif [[ ${cur} == -* ]]; then
-            opts="-l -e -r"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-
-
-        # NOTE: This slows things down!
-        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
-        # This removes any options from the list of completions that have
-        # already been specified on the command line.
-        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
-        (while read -d ' ' i; do
-            [[ -z ${i} ]] && continue
-            # flatten array with spaces on either side,
-            # otherwise we cannot grep on word boundaries of
-            # first and last word
-            COMPREPLY=" ${COMPREPLY[@]} "
-            # remove word from list of completions
-            COMPREPLY=(${COMPREPLY/ ${i%% *} / })
-        done
-        echo ${COMPREPLY[@]})))
-
-            return 0
-    # if no option typed
-    else
-        if [[ ${COMP_CWORD} -eq 1 ]]; then              # if first word typed
-            words="`rc-service -l | grep ^${cur}`"          # complete for init scripts
-            COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-            done))
-            return 0
-        elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
-            filename=`rc-service -r ${prev}`
-            opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"`    # Greps the functions included in the init script
-            if [[ "x${opts}" == "x" ]] ; then               # if no options found loosen the grep algorhythm
-                opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
-            fi
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-    fi
-    if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
-          [[ ${action} == '--resolve' ]]  || [[ ${action} == '-r' ]]; then
-        words="`rc-service -l | grep ^${cur}`"
-        COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-        done))
-        return 0
-    fi
-
-    return 0
-} &&
-complete -F _rc_service rc-service
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/glsa-check b/completions/glsa-check
new file mode 100644
index 0000000..76f6466
--- /dev/null
+++ b/completions/glsa-check
@@ -0,0 +1,33 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_glsa_check() {
+    local cur opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
+    --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
+    -c --cve -m --mail"
+
+    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    # too slow otherwise
+    if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
+        [[ $(stat ${ROOT}/tmp/gc.out | \
+        sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
+    then
+        glsa-check -nl 2>/dev/null | \
+            sed -n -e  's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
+                ${ROOT}/tmp/gc.out
+    fi
+
+    COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
+} &&
+complete -F _glsa_check glsa-check
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/java-config b/completions/java-config
new file mode 100644
index 0000000..42bf11e
--- /dev/null
+++ b/completions/java-config
@@ -0,0 +1,158 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# java-config completion command
+#
+_javaconfig()
+{
+    local cur prev curword numwords opts args arg spec flag sedcmd grepcmd
+    local multiplepkgs pkgs execopts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+    curword=${COMP_CWORD}
+    opts=""
+    args=""
+    pkgs=""
+    sedcmd="sed -r -e s/\[([^]]+)\].*/\1/"
+    vmsedcmd="sed -r -e s/\[([^]]+)\]/\1/"
+    grepcmd="egrep -o (--set-(system|user)-(classpath|vm)=)"
+    multiplepkgs=""
+    execopts="HtmlConverter JavaPluginControlPanel \
+    appletviewer awt_robot \
+    extcheck \
+    idlj \
+    j2sdk-config jar jarsigner \
+    java java-rmi.cgi java_vm javac javadoc javah javap jdb \
+    keytool kinit klist ktab \
+    native2ascii \
+    oldjava oldjavac oldjdb orbd \
+    policytool \
+    realpath rmic rmid rmiregistry \
+    serialver servertool \
+        tnameserv"
+    if [[ "${cur}" == -* ]] || [ ${curword} -eq 1 ]; then
+    case "${cur}" in
+        --java)
+        opts="--java --javac --java-version"
+        ;;
+        --j@(a@(r|va@(c|-version))|@(dk|re)-home))
+        opts=""
+        ;;
+        --list-available-@(packages|vms))
+        opts=""
+        ;;
+        --@(exec|set-@(user|system)-@(classpath|vm)))
+        opts="${cur}="
+        ;;
+        --set-@(user|system)-@(classpath|vm)=)
+        if [[ "${cur}" == "--set-system-vm=" ]] || [[ "${cur}" == "--set-user-vm=" ]]; then
+            flag="--list-available-vms"
+            args=$(java-config --nocolor "${flag}" | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
+        else
+            flag="--list-available-packages"
+            args=$(java-config --nocolor "${flag}" | ${sedcmd})
+        fi
+        for arg in ${args}; do
+            [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+        done
+        COMPREPLY=($(compgen $nospace -W "${opts}"))
+        return 0
+        ;;
+        --exec=)
+        COMPREPLY=($(compgen $nospace -W "${execopts}"))
+        return 0
+        ;;
+        *)
+            if [[ "${cur}" == "--set-system-vm="* ]] || [[ "${cur}" == "--set-user-vm="* ]]; then
+            args=$(java-config --nocolor --list-available-vms | cut --delimiter=' ' --fields=2 | ${vmsedcmd})
+            if [[ "${cur}" == "--set-system-vm="* ]]; then
+            spec=${cur##--set-system-vm=}
+            else
+            spec=${cur##--set-user-vm=}
+            fi
+            for arg in ${args}; do
+            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+            fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        elif [[ "${cur}" == "--set-system-classpath="* ]] || [[ "${cur}" == "--set-user-classpath="* ]]; then
+            args=$(java-config --nocolor --list-available-packages | ${sedcmd})
+            [[ $(echo "${cur}" | grep -c ",") -gt 0 ]] && multiplepkgs="true"
+            if [[ "${cur}" == "--set-system-classpath="* ]]; then
+            spec="${cur##--set-system-classpath=}"
+            else
+            spec="${cur##--set-user-classpath=}"
+            fi
+            if [[ -n "${multiplepkgs}" ]]; then
+            pkgs="${spec%,*}"
+            spec="${spec##*,}"
+            fi
+            if [[ -n "${multiplepkgs}" ]]; then
+                for arg in ${args}; do
+                if [[ "${spec}" ]]; then
+                    if [[ "${arg:0:${#spec}}" == "${spec}" ]] \
+                        && [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]
+                                then
+                    [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
+                    fi
+                else
+                    if [[ ! $(echo "${cur}" | egrep -o "(=|,)${arg},") ]]; then
+                        [[ -n "${opts}" ]] && opts="${opts} ${pkgs},${arg}" || opts="${pkgs},${arg}"
+                    fi
+                fi
+                done
+            [[ "${opts}" == "${pkgs},${spec}" ]] && opts=""
+            else
+                for arg in ${args}; do
+                if [[ "${spec}" ]] && [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+                fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            fi
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        elif [[ "${cur}" == "--exec="* ]]; then
+            spec=${cur##--exec=}
+            for arg in ${execopts}; do
+            if [[ "${arg:0:${#spec}}" == "${spec}" ]]; then
+                [[ -n "${opts}" ]] && opts="${opts} ${arg}" || opts="${arg}"
+            fi
+            done
+            [[ "${opts}" == "${spec}" ]] && opts=""
+            COMPREPLY=($(compgen -W "${opts}"))
+            return 0
+        else
+            opts="--classpath --clean-system-classpath --clean-user-classpath \
+                --exec \
+            --full-classpath \
+                --jar --java --javac --java-version --jdk-home --jre-home \
+                --list-available-packages --list-available-vms \
+            --nocolor \
+            --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
+            [[ "$prev" == "--nocolor" ]] && opts="${opts/--nocolor}"
+        fi
+            ;;
+        esac
+    elif [[ "$prev" == "--nocolor" ]] && [ ${curword} -eq 2 ] && [ $numwords -le 3 ]; then
+    opts="--classpath --clean-system-classpath --clean-user-classpath \
+        --exec \
+        --full-classpath \
+        --jar --java --javac --java-version --jdk-home --jre-home \
+        --list-available-packages --list-available-vms \
+        --set-system-classpath --set-system-vm --set-user-classpath --set-user-vm"
+    fi
+    COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur}))
+    return 0
+} &&
+complete $nospace -F _javaconfig java-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/metagen b/completions/metagen
new file mode 100644
index 0000000..3ba0dc9
--- /dev/null
+++ b/completions/metagen
@@ -0,0 +1,30 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_metagen() {
+    local cur prev opts
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    opts="$(_parse_help ${COMP_WORDS[0]})"
+
+    case $prev in
+        -h|--help|--version)
+            return 0
+            ;;
+        -H|-e|-n|-d|-l)
+            return 0
+            ;;
+        -o)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+    return 0
+} &&
+complete -F _metagen metagen
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/portageq b/completions/portageq
new file mode 100644
index 0000000..7922e59
--- /dev/null
+++ b/completions/portageq
@@ -0,0 +1,87 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# portageq completion
+#
+
+_portageq() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    opts="config_protect_mask \
+      config_protect \
+      vdb_path \
+      gentoo_mirrors \
+      all_best_visible \
+      match \
+      best_visible \
+      mass_best_visible \
+      has_version \
+      portdir \
+      envvar \
+      mass_best_version \
+      best_version \
+      pkgdir \
+      portdir_overlay \
+      distdir"
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+    # would always be correct, but it's pretty slow...
+    #COMPREPLY=($(compgen -W "$(portageq | grep '^   [[:lower:]]' | \
+    #    sed -e 's/^.*[[:space:]]\([[:lower:]_]\+\)[[:space:]].*$/\1/')" \
+    #    -- ${cur}))
+    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+    fi
+
+    case "${prev}" in
+    config*|vdb_path|gentoo_mirrors|*dir*)
+        COMPREPLY=()
+        ;;
+
+    # this also isn't the fastest, but I welcome an alternative method
+    envvar)
+        COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
+                sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
+        ;;
+
+    *v@(isible|ersion)|match)
+        COMPREPLY=($(compgen $nospace -W '/' -- $cur))
+        ;;
+
+    # $prev is a path, so complete on category/package
+    */*)
+            local x a=0
+            for x in ${COMP_WORDS[@]} ; do
+                # This is the only one
+                if [[ "${x}" == "all_best_visible" ]] ; then
+                    a=1
+                    break
+                fi
+            done
+
+            if [[ ${a} -eq 1 ]] ; then
+                COMPREPLY=()
+            else
+                # Check for conditional.
+#                cond="${cur%%[A-Za-z0-9]*}"
+#                cur="${cur:${#cond}}"
+
+#                if [[ -n "${cond}" ]] ; then
+#                    _pkgname -A $cur
+#                else
+                    _pkgname -A $cur
+#                fi
+            fi
+        ;;
+    esac
+} &&
+complete -F _portageq portageq
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc b/completions/rc
new file mode 100644
index 0000000..7453ed4
--- /dev/null
+++ b/completions/rc
@@ -0,0 +1,21 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc completion command
+#
+_rc()
+{
+    local cur
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
+    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    fi
+    return 0
+} &&
+complete -F _rc rc
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-service b/completions/rc-service
new file mode 100644
index 0000000..9ad2ce1
--- /dev/null
+++ b/completions/rc-service
@@ -0,0 +1,111 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_rc_service() {
+    local cur prev numwords opts
+    local words i x filename
+    local action actionpos
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+            COMPREPLY=($(compgen -f -- ${cur}))
+            return 0
+        fi
+
+    # find action
+    for x in ${COMP_LINE} ; do
+        if [[ ${x} =~ --(list|exists|resolve) ]] || \
+            [[ ${x} =~ -(l|e|r) ]]
+        then
+            action=${x}
+            break
+        fi
+    done
+    if [[ -n ${action} ]]; then
+        for ((i = 0; i < ${numwords}; i++ )); do
+            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
+                actionpos=${i}
+                break
+            fi
+        done
+
+        for ((i = 1; i < ${numwords}; i++ )); do
+            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
+                break
+            fi
+        done
+    fi
+
+    if [[ ${COMP_CWORD} -eq 3 ]]; then
+        return 1
+    fi
+
+    # check if an option was typed
+    if [[ ${cur} == -* ]]; then
+        if [[ ${cur} == --* ]]; then
+            opts="--list --exists --resolve"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        elif [[ ${cur} == -* ]]; then
+            opts="-l -e -r"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        fi
+
+
+        # NOTE: This slows things down!
+        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
+        # This removes any options from the list of completions that have
+        # already been specified on the command line.
+        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
+        (while read -d ' ' i; do
+            [[ -z ${i} ]] && continue
+            # flatten array with spaces on either side,
+            # otherwise we cannot grep on word boundaries of
+            # first and last word
+            COMPREPLY=" ${COMPREPLY[@]} "
+            # remove word from list of completions
+            COMPREPLY=(${COMPREPLY/ ${i%% *} / })
+        done
+        echo ${COMPREPLY[@]})))
+
+            return 0
+    # if no option typed
+    else
+        if [[ ${COMP_CWORD} -eq 1 ]]; then              # if first word typed
+            words="`rc-service -l | grep ^${cur}`"          # complete for init scripts
+            COMPREPLY=($(for i in ${words} ; do \
+            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+            done))
+            return 0
+        elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
+            filename=`rc-service -r ${prev}`
+            opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"`    # Greps the functions included in the init script
+            if [[ "x${opts}" == "x" ]] ; then               # if no options found loosen the grep algorhythm
+                opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
+            fi
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+        fi
+    fi
+    if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
+          [[ ${action} == '--resolve' ]]  || [[ ${action} == '-r' ]]; then
+        words="`rc-service -l | grep ^${cur}`"
+        COMPREPLY=($(for i in ${words} ; do \
+            [[ ${i} == ${cur}* ]] && echo ${i} ; \
+        done))
+        return 0
+    fi
+
+    return 0
+} &&
+complete -F _rc_service rc-service
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-status b/completions/rc-status
new file mode 100644
index 0000000..794067f
--- /dev/null
+++ b/completions/rc-status
@@ -0,0 +1,28 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc-status completion command
+#
+_rcstatus()
+{
+    local cur
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ $COMP_CWORD -eq 1 ]]; then
+        if [[ "${cur}" == --* ]]; then
+        COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
+    elif [[ "${cur}" == -* ]]; then
+        COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
+    else
+        COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
+    fi
+    else
+    unset COMPREPLY
+    fi
+    return 0
+} &&
+complete -F _rcstatus rc-status
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-update b/completions/rc-update
new file mode 100644
index 0000000..ae45744
--- /dev/null
+++ b/completions/rc-update
@@ -0,0 +1,40 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# rc-update completion command
+#
+_rcupdate()
+{
+    local cur show
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    if [[ $COMP_CWORD -eq 1 ]]; then
+    if [[ "${cur}" == -* ]]; then
+        COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
+    else
+        COMPREPLY=($(compgen -W 'add del show' ${cur}))
+    fi
+    else
+        if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
+        show="TRUE"
+    fi
+    if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
+            ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
+        then
+        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    elif [[ $COMP_CWORD -eq 2 ]]; then
+        COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
+    elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
+        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
+    else
+        unset COMPREPLY
+    fi
+    fi
+    return 0
+} &&
+complete -F _rcupdate rc-update
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/revdep-rebuild b/completions/revdep-rebuild
new file mode 100644
index 0000000..cb0efe7
--- /dev/null
+++ b/completions/revdep-rebuild
@@ -0,0 +1,55 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+_revdep_rebuild() {
+    local cur prev numwords opts
+    local words i x
+    local action actionpos
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    numwords=${#COMP_WORDS[*]}
+
+    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
+            COMPREPLY=($(compgen -f -- ${cur}))
+            return 0
+        fi
+
+    # find action
+    for ((i = 0; i < ${numwords}; i++ )); do
+        case ${COMP_WORDS[${i}]} in
+            --library|-L)
+                action=${COMP_WORDS[${i}]}
+                actionpos=${i}
+                ;;
+            --help|-h)
+                action=${COMP_WORDS[${i}]}
+                actionpos=${i}
+                ;;
+        esac
+    done
+
+    if [[ ${cur} == -* ]]; then
+        if [[ ${cur} == --* ]]; then
+            opts="--exact --help --ignore --keep-temp --library --nocolor --no-ld-path --no-order --no-progress --no-util --pretend --quiet --verbose"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        else
+            opts="-e -h -i -k -L -l -o -p -P -q -u -v"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        fi
+        return 0
+    fi
+    if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then
+        if [[ "${cur}" == */* ]]; then
+            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") )
+        else
+            COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -X '/' -f -- "${cur}") )
+        fi
+    fi
+    return 0
+} &&
+complete -F _revdep_rebuild revdep-rebuild
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/splat b/completions/splat
new file mode 100644
index 0000000..ddae6a0
--- /dev/null
+++ b/completions/splat
@@ -0,0 +1,33 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+_splat() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help -v --verbose -s --summary -f --logfile -c --colored -l
+    --list -u --count -p --package -t --sort -r --reverse"
+
+    if [[ ${cur} == -* ]] ; then
+        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        -f|--logfile)
+            COMPREPLY=($(compgen -f -- ${cur}))
+            ;;
+        *)
+            _pkgname -A ${cur}
+            COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur}))
+            ;;
+    esac
+} &&
+complete -o filenames -F _splat splat
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/webapp-config b/completions/webapp-config
new file mode 100644
index 0000000..01679b5
--- /dev/null
+++ b/completions/webapp-config
@@ -0,0 +1,169 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# webapp-config completion
+#
+
+_webapp_complete_appver()
+{
+    local x proot ibase cur="$2"
+    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+        echo proot="${MY_PERSISTROOT:-@GENTOO_PORTAGE_EPREFIX@/var/db/webapps}" ; \
+        echo ibase="${WA_INSTALLSBASE:-installs}")
+
+    case "$1" in
+    # complete on installed
+    installed)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/*/*/installs ; do \
+            if [[ -f "${x}" ]] ; then \
+            local y="${x%/*}" ; \
+            y="${y%/*}" ; \
+            echo "${y##*/}" ; \
+            fi ; \
+        done)" -- ${cur}))
+        ;;
+
+    # complete on uninstalled
+    uninstalled)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/*/* ; do \
+            if [[ ! -f "${x}/${ibase}" ]] ; then \
+            local y="${x%/*}" ; \
+            echo "${y##*/}" ; \
+            fi ; \
+        done)" -- ${cur}))
+        ;;
+
+    # all
+    all)
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/* ; do \
+            [[ -d "${x}" ]] && echo "${x##*/}" ; \
+        done)" -- ${cur}))
+        ;;
+
+    # complete on version
+    *)
+        [[ -d "${proot}/$1" ]] || return 1
+        COMPREPLY=($(compgen -W "$(\
+        for x in ${proot}/$1/* ; do \
+            [[ -d "${x}" ]] && echo "${x##*/}" ; \
+        done)" -- ${cur}))
+        ;;
+    esac
+}
+
+_webapp_config()
+{
+    local cur prev actions opts hostroot
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    actions="-I --install -U --upgrade -C --clean --list-installs \
+    --list-unused-installs --show-installed --show-postinst \
+    --help -v --version"
+    opts="--bug-report --pretend -p -u --user -g --group \
+    -d --dir -h --host -V --verbose --soft --secure --virtual-dirs \
+    --virtual-files --force-virtual"
+
+    eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+    echo hostroot="${VHOST_ROOT:-@GENTOO_PORTAGE_EPREFIX@/var/www}")
+
+    # --bug-report, --pretend, and -p can only be used as first arg
+    if [[ ${COMP_CWORD} -gt 1 ]] ; then
+        opts="${opts/--bug-report --pretend -p}"
+    fi
+
+    if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
+        return 0
+    fi
+
+    case "${prev}" in
+        --bug-report|-p|--pretend)
+        COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur}))
+        ;;
+
+        -I|--install)
+            _webapp_complete_appver all ${cur}
+            ;;
+
+        -U|--upgrade)
+            _webapp_complete_appver installed ${cur}
+            ;;
+
+        # only complete on -d since it is required if -C is specified
+        -C|--clean)
+            COMPREPLY=($(compgen -W "-d" -- ${cur}))
+            ;;
+
+        --list-unused-installs)
+            _webapp_complete_appver uninstalled ${cur}
+            ;;
+
+        --list-installs|--show-postinst)
+            _webapp_complete_appver all ${cur}
+            ;;
+
+        #  hrm... anyone know a better way to reliably do this?
+        -h|--host)
+            local x
+            COMPREPLY=($(compgen -W "$(\
+                for x in ${hostroot}/* ; do \
+                    [[ -d "${x}" ]] && echo "${x##*/}" ; \
+                done)" -- ${cur}))
+            ;;
+
+        --virtual*)
+            COMPREPLY=($(compgen -W "server-owned config-owned virtual" \
+            -- ${cur}))
+            ;;
+
+        -d|--dir)
+        local host x i=0
+                # see if --host has been specified, and if so, get the value
+                # that was passed to it.
+        for x in ${COMP_WORDS[@]} ; do
+            if [[ "${x}" == "-h" || "${x}" == "--host" ]] ; then
+            host="${COMP_WORDS[((i+1))]}"
+            break
+            fi
+            i=$((i+1))
+        done
+
+                # otherwise, use the default host
+        if [[ "${host}" == "" ]] ; then
+            eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \
+            echo host="${VHOST_HOSTNAME:-localhost}")
+        fi
+
+            COMPREPLY=($(compgen -W "$(\
+            for x in ${hostroot}${host}/* ; do \
+            [[ -d "${x}" ]] && echo "${x}" ; \
+            done)" -- ${cur}))
+            ;;
+        -u|--user)
+            COMPREPLY=($(compgen -u -- ${cur}))
+            ;;
+        -g|--group)
+            COMPREPLY=($(compgen -g -- ${cur}))
+            ;;
+
+        # we haven't recognized it yet, so more than likely ${prev}
+        # is a 'app-name' ; assuming it is indeed a valid 'app-name'
+        # (_webapp_complete_appver does the check), complete on available
+        # 'app-version's
+        *)
+            _webapp_complete_appver ${prev} ${cur} || \
+                    _webapp_complete_appver all ${cur}
+            ;;
+    esac
+} &&
+complete -F _webapp_config webapp-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2018-03-02 18:06 Michał Górny
  0 siblings, 0 replies; 34+ messages in thread
From: Michał Górny @ 2018-03-02 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     a5c0c7a1c5610f8040ea1fdb1d0a1f8c4d2f45b3
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Mon Feb 15 00:15:46 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Mar  2 18:06:51 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=a5c0c7a1

add completion for emerge --rage-clean

This PR adds the --rage-clean option.

Closes: https://github.com/gentoo/gentoo-bashcomp/pull/2

 completions/emerge | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index a7d1f52..d7da227 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -29,7 +29,7 @@ _emerge()
     # find action
     for x in ${COMP_LINE} ; do
         if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
-            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|regen|resume|search|sync|unmerge) ]]
+            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|rage-clean|regen|resume|search|sync|unmerge) ]]
         then
             action=${x}
             break
@@ -101,7 +101,7 @@ _emerge()
                 --newuse --noconfmem --nodeps --noreplace --nospinner \
                 --oneshot --onlydeps \
                 --pretend --prune \
-                --quiet \
+                --quiet --rage-clean \
                 --reinstall=changed-use --regen \
                 --search \
                 --sync \
@@ -153,7 +153,7 @@ _emerge()
     fi
 
     # Complete on installed packages when unmerging.
-    if [[ "${action}" == '--unmerge' ]]; then
+    if [[ "${action}" =~ --(rage-clean|unmerge) ]]; then
     if [[ -n "${cur}" ]] ; then
         if [[ "${cur}" == */* ]]; then
         words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2018-03-02 18:06 Michał Górny
  0 siblings, 0 replies; 34+ messages in thread
From: Michał Górny @ 2018-03-02 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     5c9fbe55124aef398e9e23186a1ef83e592a09d4
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Thu Jan  7 10:35:56 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Mar  2 18:06:45 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=5c9fbe55

Add completion for emerge --autounmask-write

Closes: https://github.com/gentoo/gentoo-bashcomp/pull/1

 completions/emerge | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/completions/emerge b/completions/emerge
index 63c02b4..a7d1f52 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -86,7 +86,8 @@ _emerge()
             fi
         elif [[ ${cur} == --* ]]; then
             # Complete on long options.
-            opts="--alphabetical --ask \
+            opts="--alphabetical \
+                --ask --autounmask-write \
                 --buildpkg --buildpkgonly \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
                 --debug --deep --depclean \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2018-03-02 18:35 William Hubbs
  0 siblings, 0 replies; 34+ messages in thread
From: William Hubbs @ 2018-03-02 18:35 UTC (permalink / raw
  To: gentoo-commits

commit:     41d0608e51e5fe3b5034de9ae3700c2490380e2e
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  2 18:33:51 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Mar  2 18:35:09 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=41d0608e

Remove OpenRC completions since they are provided upstream

 completions/rc         |  21 ----------
 completions/rc-service | 111 -------------------------------------------------
 completions/rc-status  |  28 -------------
 completions/rc-update  |  40 ------------------
 4 files changed, 200 deletions(-)

diff --git a/completions/rc b/completions/rc
deleted file mode 100644
index 7453ed4..0000000
--- a/completions/rc
+++ /dev/null
@@ -1,21 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-#
-# rc completion command
-#
-_rc()
-{
-    local cur
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
-    COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    fi
-    return 0
-} &&
-complete -F _rc rc
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-service b/completions/rc-service
deleted file mode 100644
index 9ad2ce1..0000000
--- a/completions/rc-service
+++ /dev/null
@@ -1,111 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-source "@helpersdir@/gentoo-common.sh"
-
-_rc_service() {
-    local cur prev numwords opts
-    local words i x filename
-    local action actionpos
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-
-    if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
-            COMPREPLY=($(compgen -f -- ${cur}))
-            return 0
-        fi
-
-    # find action
-    for x in ${COMP_LINE} ; do
-        if [[ ${x} =~ --(list|exists|resolve) ]] || \
-            [[ ${x} =~ -(l|e|r) ]]
-        then
-            action=${x}
-            break
-        fi
-    done
-    if [[ -n ${action} ]]; then
-        for ((i = 0; i < ${numwords}; i++ )); do
-            if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
-                actionpos=${i}
-                break
-            fi
-        done
-
-        for ((i = 1; i < ${numwords}; i++ )); do
-            if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
-                break
-            fi
-        done
-    fi
-
-    if [[ ${COMP_CWORD} -eq 3 ]]; then
-        return 1
-    fi
-
-    # check if an option was typed
-    if [[ ${cur} == -* ]]; then
-        if [[ ${cur} == --* ]]; then
-            opts="--list --exists --resolve"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        elif [[ ${cur} == -* ]]; then
-            opts="-l -e -r"
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-
-
-        # NOTE: This slows things down!
-        # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
-        # This removes any options from the list of completions that have
-        # already been specified on the command line.
-        COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
-        (while read -d ' ' i; do
-            [[ -z ${i} ]] && continue
-            # flatten array with spaces on either side,
-            # otherwise we cannot grep on word boundaries of
-            # first and last word
-            COMPREPLY=" ${COMPREPLY[@]} "
-            # remove word from list of completions
-            COMPREPLY=(${COMPREPLY/ ${i%% *} / })
-        done
-        echo ${COMPREPLY[@]})))
-
-            return 0
-    # if no option typed
-    else
-        if [[ ${COMP_CWORD} -eq 1 ]]; then              # if first word typed
-            words="`rc-service -l | grep ^${cur}`"          # complete for init scripts
-            COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-            done))
-            return 0
-        elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
-            filename=`rc-service -r ${prev}`
-            opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"`    # Greps the functions included in the init script
-            if [[ "x${opts}" == "x" ]] ; then               # if no options found loosen the grep algorhythm
-                opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
-            fi
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-        fi
-    fi
-    if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
-          [[ ${action} == '--resolve' ]]  || [[ ${action} == '-r' ]]; then
-        words="`rc-service -l | grep ^${cur}`"
-        COMPREPLY=($(for i in ${words} ; do \
-            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-        done))
-        return 0
-    fi
-
-    return 0
-} &&
-complete -F _rc_service rc-service
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-status b/completions/rc-status
deleted file mode 100644
index 794067f..0000000
--- a/completions/rc-status
+++ /dev/null
@@ -1,28 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-#
-# rc-status completion command
-#
-_rcstatus()
-{
-    local cur
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-        if [[ "${cur}" == --* ]]; then
-        COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
-    elif [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
-    fi
-    else
-    unset COMPREPLY
-    fi
-    return 0
-} &&
-complete -F _rcstatus rc-status
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80

diff --git a/completions/rc-update b/completions/rc-update
deleted file mode 100644
index ae45744..0000000
--- a/completions/rc-update
+++ /dev/null
@@ -1,40 +0,0 @@
-# Gentoo Linux Bash Shell Command Completion
-#
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-#
-# rc-update completion command
-#
-_rcupdate()
-{
-    local cur show
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    if [[ $COMP_CWORD -eq 1 ]]; then
-    if [[ "${cur}" == -* ]]; then
-        COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
-    else
-        COMPREPLY=($(compgen -W 'add del show' ${cur}))
-    fi
-    else
-        if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
-        show="TRUE"
-    fi
-    if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
-            ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
-        then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    elif [[ $COMP_CWORD -eq 2 ]]; then
-        COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
-    elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
-        COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
-    else
-        unset COMPREPLY
-    fi
-    fi
-    return 0
-} &&
-complete -F _rcupdate rc-update
-
-# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2018-06-23 22:23 Patrice Clement
  0 siblings, 0 replies; 34+ messages in thread
From: Patrice Clement @ 2018-06-23 22:23 UTC (permalink / raw
  To: gentoo-commits

commit:     48adce4356f46eda30265d2c5a6cb4055c16c5e3
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Sun Jun 10 16:26:46 2018 +0000
Commit:     Patrice Clement <monsieurp <AT> gentoo <DOT> org>
CommitDate: Sat Jun 23 22:23:00 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=48adce43

emerge: add support for sets completion.

Based on Marco Genasci's patch and slightly modified to get rid of the
unnecessary call to xargs.

Courtesy of Marco Genasci <fedeliallalinea <AT> gmail.com>.

Closes: https://bugs.gentoo.org/235454
Closes: https://github.com/gentoo/gentoo-bashcomp/pull/4

 completions/emerge | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/completions/emerge b/completions/emerge
index d7da227..03cc503 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -26,6 +26,12 @@ _emerge()
         return 0
     fi
 
+    if [[ ${cur} =~ ^@ ]] ; then
+        local SET_LIST=($(emerge --list-sets))
+        COMPREPLY=($(compgen -W '${SET_LIST[@]/#/@}' ${cur}))
+        return 0
+    fi
+
     # find action
     for x in ${COMP_LINE} ; do
         if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2023-01-14 16:38 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2023-01-14 16:38 UTC (permalink / raw
  To: gentoo-commits

commit:     a7513c33fc3744c7664c8c6c9c3c1bb22f0b0ab9
Author:     Louis Sautier <sautier.louis <AT> gmail <DOT> com>
AuthorDate: Sat Nov  5 23:16:06 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jan 14 16:38:46 2023 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=a7513c33

emerge: add support for --deselect

Signed-off-by: Louis Sautier <sautier.louis <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo-bashcomp/pull/6
Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index 03cc503..e84a7fc 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -35,7 +35,7 @@ _emerge()
     # find action
     for x in ${COMP_LINE} ; do
         if [[ ${x} =~ ^(system|world)$ ]] || [[ ${x} =~ -[CPcs] ]] || \
-            [[ ${x} =~ --(clean|config|depclean|info|metadata|prune|rage-clean|regen|resume|search|sync|unmerge) ]]
+            [[ ${x} =~ --(clean|config|depclean|deselect|info|metadata|prune|rage-clean|regen|resume|search|sync|unmerge) ]]
         then
             action=${x}
             break
@@ -96,7 +96,7 @@ _emerge()
                 --ask --autounmask-write \
                 --buildpkg --buildpkgonly \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
-                --debug --deep --depclean \
+                --debug --deep --depclean --deselect \
                 --emptytree \
                 --fetch-all-uri --fetchonly \
                 --getbinpkg --getbinpkgonly \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2023-03-13 21:27 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2023-03-13 21:27 UTC (permalink / raw
  To: gentoo-commits

commit:     8e15ae348f400c86a8314933a15d8f851f045281
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 13 21:26:42 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:27:22 2023 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=8e15ae34

completions/emerge: add additional options

Adds the following:
- --autounmask-keep-keywords
- --autounmask-continue
- --onlydeps-with-ideps
- --onlydeps-with-rdeps
- --update-if-installed

Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index e84a7fc..113aa07 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -93,7 +93,7 @@ _emerge()
         elif [[ ${cur} == --* ]]; then
             # Complete on long options.
             opts="--alphabetical \
-                --ask --autounmask-write \
+                --ask --autounmask-write --autounmask-keep-keywords --autounmask-continue \
                 --buildpkg --buildpkgonly \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
                 --debug --deep --depclean --deselect \
@@ -105,14 +105,14 @@ _emerge()
                 --keep-going \
                 --metadata \
                 --newuse --noconfmem --nodeps --noreplace --nospinner \
-                --oneshot --onlydeps \
+                --oneshot --onlydeps --onlydeps-with-ideps --onlydeps-with-rdeps \
                 --pretend --prune \
                 --quiet --rage-clean \
                 --reinstall=changed-use --regen \
                 --search \
                 --sync \
                 --tree \
-                --unmerge --update --upgradeonly --usepkg --usepkgonly \
+                --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly \
                 --verbose \
                 --with-bdeps=y --with-bdeps=n"
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-02-21  7:23 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-02-21  7:23 UTC (permalink / raw
  To: gentoo-commits

commit:     1f3b30d5e4d5b39601fb403db492c2f844960975
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 07:23:35 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 21 07:23:35 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=1f3b30d5

completions/emerge: add --verbose-conflicts

Bug: https://bugs.gentoo.org/924830
Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/completions/emerge b/completions/emerge
index 113aa07..915a0b0 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -113,7 +113,7 @@ _emerge()
                 --sync \
                 --tree \
                 --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly \
-                --verbose \
+                --verbose --verbose-conflicts \
                 --with-bdeps=y --with-bdeps=n"
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
                 opts="${opts} --help --resume --searchdesc --version"


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-02-21  7:34 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-02-21  7:34 UTC (permalink / raw
  To: gentoo-commits

commit:     01bd80421d77d8e538495aafffef34c23ef3cd6d
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 07:29:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 21 07:29:23 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=01bd8042

completions/emerge: add --changed-* options

* --changed-deps
* --changed-deps-report
* --changed-slot
* --changed-use

Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 1 +
 1 file changed, 1 insertion(+)

diff --git a/completions/emerge b/completions/emerge
index e813817..442acaf 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -96,6 +96,7 @@ _emerge()
                 --ask --autounmask-write --autounmask-keep-keywords --autounmask-continue \
                 --buildpkg --buildpkgonly \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
+                --changed-deps --changed-deps-report --changed-slot --changed-use \
                 --debug --deep --depclean --deselect \
                 --emptytree \
                 --fetch-all-uri --fetchonly \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-02-21  7:34 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-02-21  7:34 UTC (permalink / raw
  To: gentoo-commits

commit:     5a9c389ddbf6e1e1692d521f7e132110ec58d482
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 07:25:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 21 07:25:23 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=5a9c389d

completions/emerge: add --with-test-deps

Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/completions/emerge b/completions/emerge
index 915a0b0..e813817 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -114,7 +114,7 @@ _emerge()
                 --tree \
                 --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly \
                 --verbose --verbose-conflicts \
-                --with-bdeps=y --with-bdeps=n"
+                --with-bdeps=y --with-bdeps=n --with-test-deps"
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
                 opts="${opts} --help --resume --searchdesc --version"
             fi


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-02-21  7:34 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-02-21  7:34 UTC (permalink / raw
  To: gentoo-commits

commit:     6a3d1b3d78a174db6711deb8335ab998ec6bb6c5
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 07:34:19 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 21 07:34:19 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=6a3d1b3d

completions/emerge: add various further options

Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/completions/emerge b/completions/emerge
index 442acaf..c3be06b 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -93,12 +93,25 @@ _emerge()
         elif [[ ${cur} == --* ]]; then
             # Complete on long options.
             opts="--alphabetical \
-                --ask --autounmask-write --autounmask-keep-keywords --autounmask-continue \
+                --ask \
+                --autounmask-write --autounmask-keep-keywords --autounmask-continue \
+                --autounmask-backtrack --autounmask-only --autounmask-unrestricted-atoms \
+                --autounmask-keep-masks --autounmask-license --autounmask-use \
+                --accept-properties --accept-restrict --alert --alert=y --alert=n \
+		--ask-enter-invalid \
+		--binpkg-changed-deps --binpkg-respect-use \
+		--buildpkg-exclude \
                 --buildpkg --buildpkgonly \
+		--backtrack= \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
+		--complete-graph-if-new-use --complete-graph-if-new-ver \
+		--config-root \
                 --changed-deps --changed-deps-report --changed-slot --changed-use \
                 --debug --deep --depclean --deselect \
+		--depclean-lib-check \
+		--dynamic-deps --dynamic-deps=y --dynamic-deps=n \
                 --emptytree \
+		--exclude \
                 --fetch-all-uri --fetchonly \
                 --getbinpkg --getbinpkgonly \
                 --ignore-default-opts --info \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-02-25 20:14 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-02-25 20:14 UTC (permalink / raw
  To: gentoo-commits

commit:     1e4bcaf0c6052449fda9750d4865a275a87f4336
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 25 20:14:47 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Feb 25 20:14:47 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=1e4bcaf0

completions/emerge: fix indentation

Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/emerge | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index c3be06b..98110c4 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -98,20 +98,20 @@ _emerge()
                 --autounmask-backtrack --autounmask-only --autounmask-unrestricted-atoms \
                 --autounmask-keep-masks --autounmask-license --autounmask-use \
                 --accept-properties --accept-restrict --alert --alert=y --alert=n \
-		--ask-enter-invalid \
-		--binpkg-changed-deps --binpkg-respect-use \
-		--buildpkg-exclude \
+                --ask-enter-invalid \
+                --binpkg-changed-deps --binpkg-respect-use \
+                --buildpkg-exclude \
                 --buildpkg --buildpkgonly \
-		--backtrack= \
+                --backtrack= \
                 --changelog --clean --color=y --color=n --columns --complete-graph --config \
-		--complete-graph-if-new-use --complete-graph-if-new-ver \
-		--config-root \
+                --complete-graph-if-new-use --complete-graph-if-new-ver \
+                --config-root \
                 --changed-deps --changed-deps-report --changed-slot --changed-use \
                 --debug --deep --depclean --deselect \
-		--depclean-lib-check \
-		--dynamic-deps --dynamic-deps=y --dynamic-deps=n \
+                --depclean-lib-check \
+                --dynamic-deps --dynamic-deps=y --dynamic-deps=n \
                 --emptytree \
-		--exclude \
+                --exclude \
                 --fetch-all-uri --fetchonly \
                 --getbinpkg --getbinpkgonly \
                 --ignore-default-opts --info \


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-11  3:12 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-05-11  3:12 UTC (permalink / raw
  To: gentoo-commits

commit:     aa32f1e126bdf947efc012d4d6b93a7150d74b24
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Fri May 10 11:59:16 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May 11 03:11:17 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=aa32f1e1

portageq envvar: preserve PATH to avoid command validation warnings

Some of Portage's environment variables undergo command validation.
When one is set to a relative value, Portage relies on PATH to find the
binary.
We need to preserve it after purging the environment (`env -i`) if we
want to avoid "<key> is invalid: <value>" warnings.

For Portage 3.0.63, this affects
PORTAGE_{B{,UN}ZIP2_COMMAND,LOG_FILTER_FILE_CMD}.

Bug: https://bugs.gentoo.org/588642
Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/portageq | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/completions/portageq b/completions/portageq
index 7922e59..a8a113b 100644
--- a/completions/portageq
+++ b/completions/portageq
@@ -47,7 +47,7 @@ _portageq() {
 
     # this also isn't the fastest, but I welcome an alternative method
     envvar)
-        COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \
+        COMPREPLY=($(compgen -W "$(env -i PATH="${PATH}" emerge -v --info | \
                 sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
         ;;
 


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-11  3:12 Sam James
  0 siblings, 0 replies; 34+ messages in thread
From: Sam James @ 2024-05-11  3:12 UTC (permalink / raw
  To: gentoo-commits

commit:     63aae2a1775e501678290c6dbeac53215decffc2
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Fri May 10 12:07:16 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May 11 03:11:51 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=63aae2a1

portageq envvar: fix variables selected for completion

With lines like VAR="foo" BAZ="1 2 3", \(.*\)=".*$ not only matches VAR,
but also VAR="foo" BAZ.
This applies at line ^USE=.*, where the regular USE flags are followed
by a list of all present USE_EXPAND variables together with their
respective values.

The current sed invocation also ignores environment variables that start
with a lowercase letter, such as gl_cv_compiler_check_decl_option.

Closes: https://bugs.gentoo.org/931671
Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 completions/portageq | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/completions/portageq b/completions/portageq
index a8a113b..7775cc4 100644
--- a/completions/portageq
+++ b/completions/portageq
@@ -48,7 +48,7 @@ _portageq() {
     # this also isn't the fastest, but I welcome an alternative method
     envvar)
         COMPREPLY=($(compgen -W "$(env -i PATH="${PATH}" emerge -v --info | \
-                sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur}))
+                cut -s -d = -f 1)" -- ${cur}))
         ;;
 
     *v@(isible|ersion)|match)


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     3d2b3aa2fe7d534a9d17a362989f6800efd36402
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 19:26:07 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:53 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=3d2b3aa2

add completion for qfile from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qfile | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/completions/qfile b/completions/qfile
new file mode 100644
index 0000000..edf9e08
--- /dev/null
+++ b/completions/qfile
@@ -0,0 +1,45 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# qfile completion (from app-portage/portage-utils)
+#
+
+_qfile() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-S --slots -R --root-prefix -d --dir -o --orphans
+            -P --skip-plibreg --verbose -q --quiet -C --nocolor --color
+            -h --help -V --version'
+        [ARG]='-F --format -x --exclude --root'
+    )
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -x|--exclude)
+            _pkgname -I "${cur}"
+            return
+            ;;
+        -F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _filedir
+    fi
+} &&
+complete -F _qfile qfile
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     a338e2564a05127c7aa6f3170d2de3fa305a0655
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 19:38:17 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:53 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=a338e256

add completion for qdepends from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qdepends | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/completions/qdepends b/completions/qdepends
new file mode 100644
index 0000000..0c6111d
--- /dev/null
+++ b/completions/qdepends
@@ -0,0 +1,49 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# qdepends completion (from app-portage/portage-utils)
+#
+
+_qdepends() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-d --depend -r --rdepend -p --pdepend -b --bdepend -I --idepend
+            -Q --query -i --installed -t --tree -U --use -S --pretty -R --resolve
+            -v --verbose -q --quiet -C --nocolor --color -h --help -V --version'
+        [ARG]='-F --format --root'
+    )
+
+    local i pkg_type="-I"
+    for word in "${COMP_WORDS[@]}"; do
+        if [[ ${word} = "-t" || ${word} = "--tree" ]]; then
+            pkg_type="-A"
+            break
+        fi
+    done
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname ${pkg_type} "${cur}"
+    fi
+} &&
+complete -F _qdepends qdepends
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     d4ecc657ba65202265d8757478192e273c09b135
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 20:03:24 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:54 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=d4ecc657

add completion for qsize from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qsize | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/completions/qsize b/completions/qsize
new file mode 100644
index 0000000..34d1fec
--- /dev/null
+++ b/completions/qsize
@@ -0,0 +1,41 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# qsize completion (from app-portage/portage-utils)
+#
+
+_qsize() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-f --filesystem -s --sum -S --sum-only -m --megabytes
+            -k --kilobytes -b --bytes -v --verbose -q --quiet -C --nocolor
+            --color -h --help -V --version'
+        [ARG]='-i --ignore -F --format --root'
+    )
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -i|--ignore|-F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname -I "${cur}"
+    fi
+} &&
+complete -F _qsize qsize
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     6c1315e121cb90a28c6fcd00bd10eff2f527238c
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun May 12 16:00:47 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:54 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=6c1315e1

add completion for qwhich from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qwhich | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/completions/qwhich b/completions/qwhich
new file mode 100644
index 0000000..87959b9
--- /dev/null
+++ b/completions/qwhich
@@ -0,0 +1,49 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# qwhich completion (from app-portage/portage-utils)
+#
+
+_qwhich() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-I --vdb -b --binpkg -t --tree -p --pretty -d --dir
+            -R --repo -f --first -l --latest -T --novirtual -A --noacct
+            -v --verbose -q --quiet -C --nocolor --color -h --help -V --version'
+        [ARG]='-F --format --root'
+    )
+
+    local i pkg_type="-I"
+    for word in "${COMP_WORDS[@]}"; do
+        if [[ ${word} = "-t" || ${word} = "--tree" ]]; then
+            pkg_type="-A"
+            break
+        fi
+    done
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname ${pkg_type} "${cur}"
+    fi
+} &&
+complete -F _qwhich qwhich
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     a7e145507c10aad145281eea418ce3ee00bb5121
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 16:01:12 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:53 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=a7e14550

add completion for qlist from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qlist | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/completions/qlist b/completions/qlist
new file mode 100644
index 0000000..1c4c24f
--- /dev/null
+++ b/completions/qlist
@@ -0,0 +1,42 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# qlist completion (from app-portage/portage-utils)
+#
+
+_qlist() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-I --installed -k --binpkgs -t --tree -S --slots -R --repo
+            -U --umap -c --columns -m --mask --showdebug -e --exact -d --dir
+            -o --obj -s --sym -v --verbose -q --quiet -C --nocolor --color
+            -h --help -V --version'
+        [ARG]='-F --format --root'
+    )
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname -I "${cur}"
+    fi
+} &&
+complete -F _qlist qlist
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     114d592416f604caf28cfc53ce6dfb1aa1c00b72
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 16:01:44 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:53 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=114d5924

add completion for q from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/q | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/completions/q b/completions/q
new file mode 100644
index 0000000..1522235
--- /dev/null
+++ b/completions/q
@@ -0,0 +1,52 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# q completion (from app-portage/portage-utils)
+#
+
+_q() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-i --install -o --overlays -e --envvar -m --mask -v --verbose
+            -q --quiet -C --nocolor --color -h --help -V --version'
+        [APPLETS]='qatom qcheck qdepends qfile qgrep qkeyword qlist qlop
+            qmanifest qmerge qmerge qpkg qsearch qsize qtbz2 qtegrity quse
+            qwhich qxpak'
+        [ARG]='--root'
+    )
+
+    local i
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ ${COMP_WORDS[i]} != -* ]]; then
+            if [[ " ${OPTS[APPLETS]} " =~ " ${COMP_WORDS[i]} " ]]; then
+                local root_command=${COMP_WORDS[i]}
+                _command_offset ${i}
+            else
+                COMPREPLY=()
+            fi
+            return
+        fi
+
+        [[ ${i} -lt ${COMP_CWORD} && " ${OPTS[ARG]} " =~ " ${COMP_WORDS[i]} " ]] && ((i++))
+    done
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[STANDALONE]} ${OPTS[ARG]}' -- "${cur}") )
+    else
+        COMPREPLY=( $(compgen -W "${OPTS[APPLETS]}" -- "${cur}") )
+    fi
+} &&
+complete -F _q q
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     0e7fa26783d4c33346703a2ef25e56342ddac9fd
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun May 12 16:16:23 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:10:54 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=0e7fa267

add completion for qsearch from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qsearch | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/completions/qsearch b/completions/qsearch
new file mode 100644
index 0000000..4cae9d2
--- /dev/null
+++ b/completions/qsearch
@@ -0,0 +1,36 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# qsearch completion (from app-portage/portage-utils)
+#
+
+_qsearch() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-a --all -s --search -N --name-only -R --repo
+            -v --verbose -q --quiet -C --nocolor --color -h --help -V --version'
+        [ARG]='-S --desc -F --format --root'
+    )
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -S|--desc|-F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    fi
+} &&
+complete -F _qsearch qsearch
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     bfa68e78a658e1af098931dfc2ebf69bee61265f
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed May 15 19:15:36 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 19:15:36 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=bfa68e78

add completion for qkeyword from app-portage/portage-utils

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/qkeyword | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/completions/qkeyword b/completions/qkeyword
new file mode 100644
index 0000000..ebf749c
--- /dev/null
+++ b/completions/qkeyword
@@ -0,0 +1,37 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# qkeyword completion (from app-portage/portage-utils)
+#
+
+_qkeyword() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-A --showarch -i --showarch -d --showarch -t --needsstable
+            -s --stats -a --all -n --not -S --stable -T --testing
+            -v --verbose -q --quiet -C --nocolor --color -h --help -V --version'
+        [ARG]='-p --matchpkg -c --matchcat -m --matchmaint -F --format --root'
+    )
+
+    case ${prev} in
+        --root)
+            _filedir -d
+            return
+            ;;
+        -p|--matchpkg|-c|--matchcat|-m|--matchmaint|-F|--format)
+            COMPREPLY=()
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    fi
+} &&
+complete -F _qkeyword qkeyword
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-15 20:09 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-15 20:09 UTC (permalink / raw
  To: gentoo-commits

commit:     03984b3ea6dea163773af007c7109636a9676e9e
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed May 15 20:09:45 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 15 20:09:45 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=03984b3e

add completion for emaint from sys-apps/portage

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/emaint | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/completions/emaint b/completions/emaint
new file mode 100644
index 0000000..74f1e0a
--- /dev/null
+++ b/completions/emaint
@@ -0,0 +1,77 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# emaint completion (from sys-apps/portage)
+#
+
+_emaint() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [COMMANDS]='all binhost cleanresume merges movebin moveinst sync world'
+        [STANDALONE]='-h --help -c --check -f --fix --version'
+        [LOGS]='-C --clean -p --pretend'
+        [LOGS_ARG]='-t --time'
+        [MERGES]='-y --yes'
+        [SYNC]='-a --auto -A --allrepos'
+        [SYNC_ARG]='-r --repo --sync-submodule'
+    )
+
+    local i command
+    for (( i=1; i <= COMP_CWORD; i++ )); do
+        if [[ ${COMP_WORDS[i]} != -* ]]; then
+            if [[ " ${OPTS[COMMANDS]} " =~ " ${COMP_WORDS[i]} " ]]; then
+                command=${COMP_WORDS[i]}
+                break
+            else
+                COMPREPLY=( $(compgen -W '${OPTS[COMMANDS]}' -- "${cur}") )
+                return
+            fi
+        fi
+
+        [[ ${i} -lt ${COMP_CWORD} && " ${OPTS[LOGS_ARG]} ${OPTS[SYNC_ARG]} " =~ " ${COMP_WORDS[i]} " ]] && ((i++))
+    done
+
+    case ${command} in
+        logs)
+            if [[ ${prev} = -t || ${prev} = --time ]]; then
+                COMPREPLY=()
+                return
+            fi
+            ;;
+        sync)
+            case ${prev} in
+                -r|--repo)
+                    COMPREPLY=( $(compgen -W "$(_parsereposconf -l)" -- "${cur}") )
+                    return
+                    ;;
+                --sync-submodule)
+                    COMPREPLY=( $(compgen -W 'glsa news profiles' -- "${cur}") )
+                    return
+                    ;;
+            esac
+            ;;
+    esac
+
+    COMPREPLY=( $(compgen -W '${OPTS[STANDALONE]}' -- "${cur}") )
+    case ${command} in
+        logs)
+            COMPREPLY+=( $(compgen -W '${OPTS[LOGS]} ${OPTS[LOGS_ARG]}' -- "${cur}") )
+            ;;
+        merges)
+            COMPREPLY+=( $(compgen -W '${OPTS[MERGES]}' -- "${cur}") )
+            ;;
+        sync)
+            COMPREPLY+=( $(compgen -W '${OPTS[SYNC]} ${OPTS[SYNC_ARG]}' -- "${cur}") )
+            ;;
+    esac
+    if [[ -z ${command} ]]; then
+        COMPREPLY+=( $(compgen -W '${OPTS[COMMANDS]}' -- "${cur}") )
+    fi
+} &&
+complete -F _emaint emaint
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-21 17:50 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-21 17:50 UTC (permalink / raw
  To: gentoo-commits

commit:     d770066407985fbf40608f09d84f77ab23516646
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 17:50:51 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue May 21 17:50:51 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=d7700664

update completion of emerge

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/emerge | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index 2268fca..342bfc4 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -103,7 +103,7 @@ _emerge()
                 --buildpkg-exclude \
                 --buildpkg --buildpkgonly \
                 --backtrack= \
-                --changelog --clean --color=y --color=n --columns --complete-graph --config \
+                --changelog --clean --color=y --color=n --columns --complete-graph --config --check-news \
                 --complete-graph-if-new-use --complete-graph-if-new-ver \
                 --config-root \
                 --changed-deps --changed-deps-report --changed-slot --changed-use \
@@ -112,23 +112,28 @@ _emerge()
                 --dynamic-deps --dynamic-deps=y --dynamic-deps=n \
                 --emptytree \
                 --exclude \
-                --fetch-all-uri --fetchonly \
+                --fail-clean --fetch-all-uri --fetchonly --fuzzy-search \
                 --getbinpkg --getbinpkgonly \
-                --ignore-default-opts --info \
-                --jobs= \
+                --ignore-default-opts --ignore-built-slot-operator-deps --ignore-soname-deps \
+                --ignore-world --implicit-system-deps --info \
+                --jobs= --load-average= \
                 --keep-going \
-                --metadata \
-                --newuse --noconfmem --nodeps --noreplace --nospinner \
+                --misspell-suggestions --metadata \
+                --newrepo --newuse --noconfmem --nodeps --noreplace --nospinner \
                 --oneshot --onlydeps --onlydeps-with-ideps --onlydeps-with-rdeps \
-                --pretend --prune \
-                --quiet --rage-clean \
-                --reinstall=changed-use --regen \
-                --search \
-                --sync \
+                --pretend --prune --package-moves --pkg-format \
+                --quiet --quiet-build --quiet-fail --quiet-repo-display --quiet-unmerge-warn \
+                --rage-clean --regex-search-auto --read-news \
+                --reinstall=changed-use --reinstall-atoms --regen --rebuild-exclude --rebuild-ignore --rebuild-if-new-slot \
+                --rebuild-if-new-rev --rebuild-if-new-ver --rebuild-if-unbuilt --rebuilt-binaries \
+                --search --search-index --search-similarity \
+                --sync --select --selective \
+                --sync-submodule=glsa --sync-submodule=news --sync-submodule=profiles \
                 --tree \
-                --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly \
-                --verbose --verbose-conflicts \
-                --with-bdeps=y --with-bdeps=n --with-test-deps"
+                --unordered-display --use-ebuild-visibility --useoldpkg-atoms --usepkg-exclude-live \
+                --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly --usepkg-exclude \
+                --verbose --verbose-conflicts --verbose-slot-rebuilds \
+                --with-bdeps=y --with-bdeps=n --with-bdeps-auto --with-test-deps"
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
                 opts="${opts} --help --resume --searchdesc --version"
             fi


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-21 18:34 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-21 18:34 UTC (permalink / raw
  To: gentoo-commits

commit:     a5fbc58454e6cd8544096b1def1f7c30f45e97c1
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 18:34:11 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue May 21 18:34:41 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=a5fbc584

emerge: use array for opts & format the code

Closes: https://bugs.gentoo.org/924830
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/emerge | 144 +++++++++++++++++++++++++++--------------------------
 1 file changed, 73 insertions(+), 71 deletions(-)

diff --git a/completions/emerge b/completions/emerge
index 342bfc4..32a1da9 100644
--- a/completions/emerge
+++ b/completions/emerge
@@ -10,16 +10,16 @@ source "@helpersdir@/gentoo-common.sh"
 #
 _emerge()
 {
-    local c cur prev curword numwords opts cond prepend
+    local c cur prev cond prepend
     local words stophere i x
     local action actionpos sysactions pkgpos
     local portdir=$(_portdir -o)
     COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    numwords=${#COMP_WORDS[*]}
-    curword=${COMP_CWORD}
-    opts=''
+    local cur=${COMP_WORDS[COMP_CWORD]}
+    local prev=${COMP_WORDS[COMP_CWORD-1]}
+    local numwords=${#COMP_WORDS[*]}
+    local curword=${COMP_CWORD}
+    local opts=()
 
     if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
         COMPREPLY=($(compgen -f -- ${cur}))
@@ -86,69 +86,71 @@ _emerge()
         # If a resume option was specified, it needs special handling.
         if [[ ${COMP_LINE} =~ --(resume|skipfirst) ]] ; then
             if [[ ${cur} == --* ]]; then
-                opts="--ask --pretend --resume --skipfirst"
+                opts=( --ask --pretend --resume --skipfirst )
             elif [[ ${cur} == -* ]]; then
-                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts="-a -p"
+                [[ ${COMP_LINE} =~ --(ask|pretend) ]] && opts=( -a -p )
             fi
         elif [[ ${cur} == --* ]]; then
             # Complete on long options.
-            opts="--alphabetical \
-                --ask \
-                --autounmask-write --autounmask-keep-keywords --autounmask-continue \
-                --autounmask-backtrack --autounmask-only --autounmask-unrestricted-atoms \
-                --autounmask-keep-masks --autounmask-license --autounmask-use \
-                --accept-properties --accept-restrict --alert --alert=y --alert=n \
-                --ask-enter-invalid \
-                --binpkg-changed-deps --binpkg-respect-use \
-                --buildpkg-exclude \
-                --buildpkg --buildpkgonly \
-                --backtrack= \
-                --changelog --clean --color=y --color=n --columns --complete-graph --config --check-news \
-                --complete-graph-if-new-use --complete-graph-if-new-ver \
-                --config-root \
-                --changed-deps --changed-deps-report --changed-slot --changed-use \
-                --debug --deep --depclean --deselect \
-                --depclean-lib-check \
-                --dynamic-deps --dynamic-deps=y --dynamic-deps=n \
-                --emptytree \
-                --exclude \
-                --fail-clean --fetch-all-uri --fetchonly --fuzzy-search \
-                --getbinpkg --getbinpkgonly \
-                --ignore-default-opts --ignore-built-slot-operator-deps --ignore-soname-deps \
-                --ignore-world --implicit-system-deps --info \
-                --jobs= --load-average= \
-                --keep-going \
-                --misspell-suggestions --metadata \
-                --newrepo --newuse --noconfmem --nodeps --noreplace --nospinner \
-                --oneshot --onlydeps --onlydeps-with-ideps --onlydeps-with-rdeps \
-                --pretend --prune --package-moves --pkg-format \
-                --quiet --quiet-build --quiet-fail --quiet-repo-display --quiet-unmerge-warn \
-                --rage-clean --regex-search-auto --read-news \
-                --reinstall=changed-use --reinstall-atoms --regen --rebuild-exclude --rebuild-ignore --rebuild-if-new-slot \
-                --rebuild-if-new-rev --rebuild-if-new-ver --rebuild-if-unbuilt --rebuilt-binaries \
-                --search --search-index --search-similarity \
-                --sync --select --selective \
-                --sync-submodule=glsa --sync-submodule=news --sync-submodule=profiles \
-                --tree \
-                --unordered-display --use-ebuild-visibility --useoldpkg-atoms --usepkg-exclude-live \
-                --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly --usepkg-exclude \
-                --verbose --verbose-conflicts --verbose-slot-rebuilds \
-                --with-bdeps=y --with-bdeps=n --with-bdeps-auto --with-test-deps"
+            opts=(
+                --alphabetical
+                --ask
+                --autounmask-write --autounmask-keep-keywords --autounmask-continue={y,n}
+                --autounmask-backtrack --autounmask-only --autounmask-unrestricted-atoms
+                --autounmask-keep-masks --autounmask-license={y,n} --autounmask-use={y,n}
+                --accept-properties --accept-restrict --alert --alert={y,n}
+                --ask-enter-invalid
+                --binpkg-changed-deps --binpkg-respect-use
+                --buildpkg-exclude
+                --buildpkg --buildpkgonly
+                --backtrack=
+                --changelog --clean --color={y,n} --columns --complete-graph --config --check-news
+                --complete-graph-if-new-use={y,n} --complete-graph-if-new-ver={y,n}
+                --config-root
+                --changed-deps --changed-deps-report --changed-slot --changed-use
+                --debug --deep --depclean --deselect
+                --depclean-lib-check
+                --dynamic-deps={y,n}
+                --emptytree
+                --exclude
+                --fail-clean --fetch-all-uri --fetchonly --fuzzy-search
+                --getbinpkg --getbinpkgonly
+                --ignore-default-opts --ignore-built-slot-operator-deps={y,n} --ignore-soname-deps={y,n}
+                --ignore-world --implicit-system-deps={y,n} --info
+                --jobs= --load-average=
+                --keep-going
+                --misspell-suggestions={y,n} --metadata
+                --newrepo --newuse --noconfmem --nodeps --noreplace --nospinner
+                --oneshot --onlydeps --onlydeps-with-ideps --onlydeps-with-rdeps
+                --pretend --prune --package-moves --pkg-format
+                --quiet --quiet-build --quiet-fail --quiet-repo-display --quiet-unmerge-warn
+                --rage-clean --regex-search-auto={y,n} --read-news
+                --reinstall=changed-use --reinstall-atoms --regen --rebuild-exclude --rebuild-ignore --rebuild-if-new-slot
+                --rebuild-if-new-rev --rebuild-if-new-ver --rebuild-if-unbuilt --rebuilt-binaries
+                --search --search-index --search-similarity
+                --sync --select --selective
+                --sync-submodule={glsa,news,profiles}
+                --tree
+                --unordered-display --use-ebuild-visibility --useoldpkg-atoms --usepkg-exclude-live
+                --unmerge --update --update-if-installed --upgradeonly --usepkg --usepkgonly --usepkg-exclude
+                --verbose --verbose-conflicts --verbose-slot-rebuilds
+                --with-bdeps={y,n} --with-bdeps-auto={y,n} --with-test-deps
+            )
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} --help --resume --searchdesc --version"
+                opts+=( --help --resume --searchdesc --version )
             fi
         elif [[ ${cur} == -* ]]; then
             # Complete on short options.
-            opts="-B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v"
+            opts+=( -B -D -G -K -N -O -a -b -d -e -f -g -k -l -n -o -p -q -t -u -v )
             if [[ ${curword} -eq 1 ]] && [[ ${numwords} -eq 2 ]] ; then
-                opts="${opts} -h -S -V"
+                opts+=( -h -S -V )
             fi
             if [[ -z ${action} ]] && [[ ${curword} -eq $((pkgpos - 1)) ]] ; then
-                opts="${opts} -C -P -c -s"
+                opts+=( -C -P -c -s )
             fi
         fi
 
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        COMPREPLY=($(compgen -W '${opts[*]}' -- ${cur}))
 
         # NOTE: This slows things down!
         # (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>)
@@ -179,11 +181,11 @@ _emerge()
 
     # Complete on installed packages when unmerging.
     if [[ "${action}" =~ --(rage-clean|unmerge) ]]; then
-    if [[ -n "${cur}" ]] ; then
-        if [[ "${cur}" == */* ]]; then
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
-        else
-        words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
+        if [[ -n "${cur}" ]] ; then
+            if [[ "${cur}" == */* ]]; then
+                words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -G "${cur}*")
+            else
+                words=$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg; compgen -S '/' -G "${cur}*")
 
                 local n=0
                 for i in ${words} ; do
@@ -193,13 +195,13 @@ _emerge()
                 if [[ ${n} -eq 1 ]] ; then
                     words="$(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -G "*-*/*")"
                 fi
+            fi
+                COMPREPLY=($(for i in ${words} ; do \
+                                [[ ${i} == ${cur}* ]] && echo ${i} ; \
+                            done))
+        else
+            COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
         fi
-            COMPREPLY=($(for i in ${words} ; do \
-                            [[ ${i} == ${cur}* ]] && echo ${i} ; \
-                        done))
-    else
-        COMPREPLY=($(builtin cd @GENTOO_PORTAGE_EPREFIX@/var/db/pkg ; compgen -S '/' -G "*-*"))
-    fi
 
         [[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg
         return 0
@@ -217,7 +219,7 @@ _emerge()
 
     # Handle cases where a conditional is specified.
     if [[ -n "${cond}" ]]; then
-    if [[ -n "${cur}" ]]; then
+        if [[ -n "${cur}" ]]; then
             if [[ ${cur} == */* ]]; then
                 if [[ ${cur} == *-[0-9]* ]] ; then
                     words="$(\
@@ -233,7 +235,7 @@ _emerge()
                             done ; \
                         done)"
                 else
-            words="$(\
+                    words="$(\
                     for pd in ${portdir} ; do \
                         builtin cd ${pd}; \
                         compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \
@@ -308,7 +310,7 @@ _emerge()
         COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
     fi
 
-        # If all else fails, try to complete on package names without the
+    # If all else fails, try to complete on package names without the
     # category being specified.
     if [[ -z "${COMPREPLY}" ]]; then
         words="$(\
@@ -413,7 +415,7 @@ _emerge()
                 builtin cd ${pd} ; \
                 compgen -S '/' -G "*-*" ; \
             done)""${sysactions}"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+        COMPREPLY=($(compgen -W "${words}" -- ${cur}))
     fi
 
     # If all else fails, try to complete on package names without the
@@ -426,7 +428,7 @@ _emerge()
                     [[ -d $i ]] && echo ${i##*/}; \
                 done ; \
             done)"
-    COMPREPLY=($(compgen -W "${words}" -- ${cur}))
+        COMPREPLY=($(compgen -W "${words}" -- ${cur}))
     fi
 
     return 0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-21 19:18 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-21 19:18 UTC (permalink / raw
  To: gentoo-commits

commit:     7fac21ea09db60e625ed47c95327836230873192
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 19:18:26 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue May 21 19:18:26 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=7fac21ea

layman: optimize speed

Closes: https://bugs.gentoo.org/526614
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/layman | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/completions/layman b/completions/layman
index c634b13..e5441ac 100644
--- a/completions/layman
+++ b/completions/layman
@@ -10,20 +10,21 @@
 
 
 _layman() {
-    local cur prev opts r_overlays l_overlays splitopt
+    local cur prev r_overlays
 
     COMPREPLY=()
 
-    opts="--version -h --help -a --add -d --delete -s --sync -i --info
+    local opts=(
+        --version -h --help -a --add -d --delete -s --sync -i --info
         -S --sync-all -L --list -l --list-local -n --nofetch -p --priority
         -c --config -O --overlay_defs -o --overlays -v --verbose -q --quiet
-        -N --nocolor -Q --quietness -W --width -k --nocheck --debug-level"
-    r_overlays="$(layman -LkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3)"
-    l_overlays="$(layman -lkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3)"
-    splitopt=false
+        -N --nocolor -Q --quietness -W --width -k --nocheck --debug-level
+    )
+    r_overlays() { layman -LkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3; }
+    l_overlays() { layman -lkNq 2>/dev/null | grep -v '^$' | cut -d' ' -f3; }
 
     _get_comp_words_by_ref -n = cur prev
-    _split_longopt && splitopt=true
+    _split_longopt && local splitopt=1
 
     case ${prev} in
         --version|-h|--help|-W|--width|-o|--overlays)
@@ -31,15 +32,16 @@ _layman() {
             return 0
             ;;
         -a|--add|-i|--info)
-            COMPREPLY=( $(compgen -W "${r_overlays}" -- "${cur}") )
+            COMPREPLY=( $(compgen -W "$(r_overlays)" -- "${cur}") )
             return 0
             ;;
         -d|--delete)
-            COMPREPLY=( $(compgen -W "${l_overlays}" -- "${cur}") )
+            COMPREPLY=( $(compgen -W "$(l_overlays)" -- "${cur}") )
             return 0
             ;;
         -s|--sync)
-            COMPREPLY=( $(compgen -W "${l_overlays} ALL" -- "${cur}") )
+            COMPREPLY=( $(compgen -W "$(l_overlays)" -- "${cur}") )
+            COMPREPLY+=( $(compgen -W "ALL" -- "${cur}") )
             return 0
             ;;
         -p|--priority)
@@ -61,9 +63,9 @@ _layman() {
             ;;
     esac
 
-    $splitopt && return 0
+    [[ -n ${splitopt} ]] && return 0
 
-    COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+    COMPREPLY=( $(compgen -W '${opts[*]}' -- "${cur}") )
 } &&
 complete -F _layman layman
 


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-21 19:25 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-21 19:25 UTC (permalink / raw
  To: gentoo-commits

commit:     725f857724ac06277423688c3f6ca8f4ea15334f
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 19:25:11 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue May 21 19:25:11 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=725f8577

add completion for eshowkw from app-portage/gentoolkit

Closes: https://bugs.gentoo.org/426570
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/eshowkw | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/completions/eshowkw b/completions/eshowkw
new file mode 100644
index 0000000..8420420
--- /dev/null
+++ b/completions/eshowkw
@@ -0,0 +1,45 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# eshowkw completion (from app-portage/gentoolkit)
+#
+
+_eshowkw() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local -A OPTS=(
+        [STANDALONE]='-h --help -v --version -B --bold -C --color -O --overlays
+            -P --prefix -S --ignore-slot'
+        [ARG]='-a --arch -A --align -T --top-position'
+    )
+
+    case ${prev} in
+        -a|--arch)
+            local portdir=$(_portdir)
+            COMPREPLY=($(compgen -W "$( grep -v \# < "${portdir}/profiles/arch.list" )" -- "${cur}"))
+            return
+            ;;
+        -A|--align)
+            COMPREPLY=($(compgen -W "top bottom" -- "${cur}"))
+            return
+            ;;
+        -T|--top-position)
+            COMPREPLY=($(compgen -W "archlist versionlist" -- "${cur}"))
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname -A "${cur}"
+    fi
+} &&
+complete -F _eshowkw eshowkw
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-22  4:53 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-22  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b812d24b004dff668f4321c51124ef086a0e506e
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed May 22 04:53:29 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 22 04:53:29 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=b812d24b

glsa-check: add missing args

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/glsa-check | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/completions/glsa-check b/completions/glsa-check
index d985429..b1ef0f1 100644
--- a/completions/glsa-check
+++ b/completions/glsa-check
@@ -4,29 +4,28 @@
 # Distributed under the terms of the GNU General Public License, v2 or later
 
 _glsa_check() {
-    local cur opts
     COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
+    local cur="${COMP_WORDS[COMP_CWORD]}"
+    local opts="-l --list -d --dump --print -t --test -p --pretend -f --fix -i
     --inject -n --nocolor -e --emergelike -h --help -V --version -v --verbose
-    -c --cve -m --mail"
+    -c --cve -m --mail -q --quiet -r --reverse"
 
     if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+        COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
         return 0
     fi
 
     # too slow otherwise
-    if [[ ! -f ${ROOT}/tmp/gc.out ]] || \
-        [[ $(stat ${ROOT}/tmp/gc.out | \
-        sed -n -e 's/^Modify: \([[:digit:]]\+-[[:digit:]]\+-[[:digit:]]\+\).*$/\1/p') != "$(date +%F)" ]]
+    local cache_file=${ROOT}/tmp/.completion.glsa-check.cache
+    if [[ ! -f ${cache_file} ]] || \
+        (( $(date +%s) - $(stat -c %Y "${cache_file}") > 4 * 3600 ))
     then
         glsa-check -nl 2>/dev/null | \
             sed -n -e  's/^\([[:digit:]]\+-[[:digit:]]\+\) .*$/\1/p' > \
-                ${ROOT}/tmp/gc.out
+                "${cache_file}"
     fi
 
-    COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur}))
+    COMPREPLY=($(compgen -W "${opts} all new affected $(< "${cache_file}")" -- "${cur}"))
 } &&
 complete -F _glsa_check glsa-check
 


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-22  5:08 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-22  5:08 UTC (permalink / raw
  To: gentoo-commits

commit:     3c6e22334e041e6816e0e069e94f8d77da078631
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed May 22 05:07:58 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed May 22 05:07:58 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=3c6e2233

ebuild: fix, refactor and update completion

Closes: https://bugs.gentoo.org/403123
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/ebuild | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/completions/ebuild b/completions/ebuild
index a268355..b86eee8 100644
--- a/completions/ebuild
+++ b/completions/ebuild
@@ -1,6 +1,6 @@
 # Gentoo Linux Bash Shell Command Completion
 #
-# Copyright 1999-2013 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License, v2 or later
 
 #
@@ -8,25 +8,26 @@
 #
 _ebuild()
 {
-    local cur opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
+    local i noopts seenf cur=${COMP_WORDS[COMP_CWORD]}
+    local cmds=(
+        help setup clean fetch digest manifest unpack compile test preinst
+        install postinst qmerge merge unmerge prerm postrm config package rpm
+        configure prepare instprep
+    )
+    local opts=( --debug --force --ignore-default-opts --skip-manifest --help )
 
-    opts="help setup clean fetch digest manifest unpack compile test preinst \
-        install postinst qmerge merge unmerge prerm postrm config package rpm \
-        configure prepare"
+    for (( i=1 ; i < ${COMP_CWORD} ; i++ )) ; do
+        [[ ${noopts} || ${COMP_WORDS[$i]/#-*} ]] && seenf=1
+        [[ ${COMP_WORDS[$i]} == "--" ]] && noopts=1
+    done
 
-    if [[ $COMP_CWORD -eq 1 ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) \
-            $(compgen -d -- ${cur}) \
-            $(compgen -W '--debug --force --help --ignore-default-opts --skip-manifest' -- ${cur}))
-
-    elif [[ $COMP_CWORD -eq 2 && "${COMP_WORDS[1]}" = "--debug --force --ignore-default-opts --skip-manifest" ]] ; then
-    COMPREPLY=($(compgen -f -X "!*.ebuild" -- ${cur}) $(compgen -d -- ${cur}))
-
-    elif [[ $COMP_CWORD -ge 2 ]] ; then
-    COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+    if [[ ${seenf} ]] ; then
+        COMPREPLY=( $(compgen -W '${cmds[*]}' -- "${cur}") )
+    else
+        _filedir ebuild
     fi
+
+    [[ ${noopts} ]] || COMPREPLY+=( $(compgen -W '${opts[*]}' -- "${cur}") )
     return 0
 } &&
 complete -o filenames -F _ebuild ebuild


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-05-27 18:50 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-05-27 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     346a97f0c7fd72a29a8c6507adf6fa2e25676ca4
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon May 27 18:50:17 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon May 27 18:50:17 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=346a97f0

add completion for perl-cleaner from app-admin/perl-cleaner

Based on code from Michal Privoznik <michal.privoznik <AT> gmail.com>

Closes: https://github.com/gentoo-perl/perl-cleaner/pull/10
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/perl-cleaner | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/completions/perl-cleaner b/completions/perl-cleaner
new file mode 100644
index 0000000..a4cf9fd
--- /dev/null
+++ b/completions/perl-cleaner
@@ -0,0 +1,41 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# perl-cleaner completion (from app-admin/perl-cleaner)
+#
+
+_perl_cleaner() {
+    local i cur prev
+    _get_comp_words_by_ref cur prev
+
+    local OPTS=(
+        -h --help -V --version -p --pretend -v --verbose -q --quite
+        --modules --allmodules --libperl --all --reallyall
+        --dont-delete-leftovers -P --package-manager
+    )
+
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ ${COMP_WORDS[i]} == -- ]]; then
+            local root_command=emerge
+            _command_offset ${i}
+            return
+        fi
+    done
+
+    case ${prev} in
+        -P|--package-manager)
+            COMPREPLY=($(compgen -W 'portage pkgcore paludis' -- "${cur}"))
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    return 0
+
+} &&
+complete -F _perl_cleaner perl-cleaner
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-06-07 10:20 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-06-07 10:20 UTC (permalink / raw
  To: gentoo-commits

commit:     5da9b01ff0e33cf0d34feda669045f42d201cd8c
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  7 10:20:22 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  7 10:20:22 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=5da9b01f

add completion for binutils-config

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/binutils-config | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/completions/binutils-config b/completions/binutils-config
new file mode 100644
index 0000000..ab7fa90
--- /dev/null
+++ b/completions/binutils-config
@@ -0,0 +1,45 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+#
+# binutils-config completion (from sys-devel/binutils-config)
+#
+_binutils-config() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+    local OPTS=(
+        -C --nocolor
+        -c --get-current-profile
+        -l --list-profiles
+        -u --uninstall
+        -d --debug
+        -B --get-bin-path
+        -L --get-lib-path
+    )
+    _list_profiles() {
+        binutils-config --nocolor --list-profiles 2>/dev/null | \
+            sed -r -e 's/\[([^]]*)\] //g' -e 's/ \*//g'
+    }
+
+    if [[ ${cur} == -* ]] ; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+        return 0
+    elif [[ ${COMP_CWORD} -eq 1 ]] ; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+        COMPREPLY+=( $(compgen -W '$(_list_profiles)' -- "${cur}" ))
+        return 0
+    fi
+
+    case ${prev} in
+        -c|--get-current-profile|-l|--list-profiles)
+            COMPREPLY=()
+            ;;
+        *)
+            COMPREPLY=( $(compgen -W '$(_list_profiles)' -- "${cur}") )
+            ;;
+    esac
+} &&
+complete -F _binutils-config binutils-config
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-06-07 10:20 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-06-07 10:20 UTC (permalink / raw
  To: gentoo-commits

commit:     90dceec2bd0941e9a31fe0b906bdc283869dbca9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  7 10:16:04 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  7 10:16:04 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=90dceec2

gcc-config: fix invalid suggestions & add missing flags

It was using the colored output and the "*" as completion options, which
was causing weird suggestions.

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/gcc-config | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/completions/gcc-config b/completions/gcc-config
index b0d0800..40d8415 100644
--- a/completions/gcc-config
+++ b/completions/gcc-config
@@ -1,42 +1,46 @@
 # Gentoo Linux Bash Shell Command Completion
 #
-# Copyright 1999-2013 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License, v2 or later
 
 #
-# gcc-config completion command
+# gcc-config completion (from sys-devel/gcc-config)
 #
 _gcc_config() {
-    local cur prev opts
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    opts="-O --use-old \
-        -P --use-portage-chost \
-        -c --get-current-profile \
-        -l --list-profiles \
-        -E --print-environ \
-        -B --get-bin-path \
-        -L --get-lib-path \
-        -X --get-stdcxx-incdir"
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+    local OPTS=(
+        -C --nocolor
+        -O --use-old
+        -f --force
+        -P --use-portage-chost
+        -c --get-current-profile
+        -l --list-profiles
+        -S --split-profile
+        -E --print-environ
+        -B --get-bin-path
+        -L --get-lib-path
+        -X --get-stdcxx-incdir
+    )
+    _list_profiles() {
+        gcc-config --nocolor --list-profiles 2>/dev/null | \
+            sed -r -e 's/\[([^]]*)\] //g' -e 's/ \*//g'
+    }
 
-    if [[ "${cur}" == -* ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+    if [[ ${cur} == -* ]] ; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
         return 0
     elif [[ ${COMP_CWORD} -eq 1 ]] ; then
-        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \
-            $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \
-                -- ${cur}) )
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+        COMPREPLY+=( $(compgen -W '$(_list_profiles)' -- "${cur}" ))
         return 0
     fi
 
-    case "${prev}" in
+    case ${prev} in
         -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles)
             COMPREPLY=()
             ;;
         *)
-            COMPREPLY=( $(compgen -W "\
-                $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) )
+            COMPREPLY=( $(compgen -W '$(_list_profiles)' -- "${cur}") )
             ;;
     esac
 } &&


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
@ 2024-06-25 16:31 Arthur Zamarin
  0 siblings, 0 replies; 34+ messages in thread
From: Arthur Zamarin @ 2024-06-25 16:31 UTC (permalink / raw
  To: gentoo-commits

commit:     20b9dd7d3e216bc07b5209f4f131e29b01363bf5
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 25 16:31:30 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 25 16:31:30 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=20b9dd7d

add completion for quickpkg

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 completions/quickpkg | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/completions/quickpkg b/completions/quickpkg
new file mode 100644
index 0000000..e5e826e
--- /dev/null
+++ b/completions/quickpkg
@@ -0,0 +1,39 @@
+# Gentoo Linux Bash Shell Command Completion
+#
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+source "@helpersdir@/gentoo-common.sh"
+
+#
+# quickpkg completion (from sys-apps/portage)
+#
+
+_quickpkg() {
+    local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    local OPTS=(
+        -h --help --umask --ignore-default-opts --include-config
+        --include-unmodified-config
+    )
+
+    case ${prev} in
+        --umask)
+            COMPREPLY=()
+            return
+            ;;
+        --include-config|--include-unmodified-config)
+            COMPREPLY=( $(compgen -W 'y n' -- "${cur}") )
+            return
+            ;;
+    esac
+
+    if [[ ${cur} = -* ]]; then
+        COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") )
+    else
+        _pkgname -I "${cur}"
+    fi
+} &&
+complete -F _quickpkg quickpkg
+
+# vim: ft=sh:et:ts=4:sw=4:tw=80


^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2024-06-25 16:31 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 19:18 [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2024-06-25 16:31 Arthur Zamarin
2024-06-07 10:20 Arthur Zamarin
2024-06-07 10:20 Arthur Zamarin
2024-05-27 18:50 Arthur Zamarin
2024-05-22  5:08 Arthur Zamarin
2024-05-22  4:53 Arthur Zamarin
2024-05-21 19:25 Arthur Zamarin
2024-05-21 18:34 Arthur Zamarin
2024-05-21 17:50 Arthur Zamarin
2024-05-15 20:09 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-15 19:25 Arthur Zamarin
2024-05-11  3:12 Sam James
2024-05-11  3:12 Sam James
2024-02-25 20:14 Sam James
2024-02-21  7:34 Sam James
2024-02-21  7:34 Sam James
2024-02-21  7:34 Sam James
2024-02-21  7:23 Sam James
2023-03-13 21:27 Sam James
2023-01-14 16:38 Sam James
2018-06-23 22:23 Patrice Clement
2018-03-02 18:35 William Hubbs
2018-03-02 18:06 Michał Górny
2018-03-02 18:06 Michał Górny
2018-03-02 18:06 Michał Górny
2014-08-31 21:19 ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox