diff options
Diffstat (limited to 'completions')
32 files changed, 757 insertions, 132 deletions
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 diff --git a/completions/browser-config b/completions/browser-config index 158ca42..9ca8507 100644 --- a/completions/browser-config +++ b/completions/browser-config @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # diff --git a/completions/distcc-config b/completions/distcc-config index 41c315f..1762ecd 100644 --- a/completions/distcc-config +++ b/completions/distcc-config @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # diff --git a/completions/ebuild b/completions/ebuild index cd6e17e..b86eee8 100644 --- a/completions/ebuild +++ b/completions/ebuild @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# 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 diff --git a/completions/ekeyword b/completions/ekeyword index 3bf3006..a182098 100644 --- a/completions/ekeyword +++ b/completions/ekeyword @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" 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 diff --git a/completions/emerge b/completions/emerge index e84a7fc..32a1da9 100644 --- a/completions/emerge +++ b/completions/emerge @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" @@ -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,50 +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 \ - --buildpkg --buildpkgonly \ - --changelog --clean --color=y --color=n --columns --complete-graph --config \ - --debug --deep --depclean --deselect \ - --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 --rage-clean \ - --reinstall=changed-use --regen \ - --search \ - --sync \ - --tree \ - --unmerge --update --upgradeonly --usepkg --usepkgonly \ - --verbose \ - --with-bdeps=y --with-bdeps=n" + 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>) @@ -160,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 @@ -174,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 @@ -198,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="$(\ @@ -214,7 +235,7 @@ _emerge() done ; \ done)" else - words="$(\ + words="$(\ for pd in ${portdir} ; do \ builtin cd ${pd}; \ compgen -X "*metadata.xml" -G "${cur}*" -- ${cur} ; \ @@ -289,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="$(\ @@ -394,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 @@ -407,7 +428,7 @@ _emerge() [[ -d $i ]] && echo ${i##*/}; \ done ; \ done)" - COMPREPLY=($(compgen -W "${words}" -- ${cur})) + COMPREPLY=($(compgen -W "${words}" -- ${cur})) fi return 0 diff --git a/completions/epkginfo b/completions/epkginfo index 34c81f3..16d5871 100644 --- a/completions/epkginfo +++ b/completions/epkginfo @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" diff --git a/completions/epm b/completions/epm index e8a8caa..c41e272 100644 --- a/completions/epm +++ b/completions/epm @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" diff --git a/completions/equery b/completions/equery index a8aa829..4cee1f1 100644 --- a/completions/equery +++ b/completions/equery @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" 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 diff --git a/completions/euse b/completions/euse index e7bed0a..5bc2f3c 100644 --- a/completions/euse +++ b/completions/euse @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" diff --git a/completions/gcc-config b/completions/gcc-config index 80e95c3..40d8415 100644 --- a/completions/gcc-config +++ b/completions/gcc-config @@ -1,42 +1,46 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# 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 } && diff --git a/completions/glsa-check b/completions/glsa-check index 76f6466..b1ef0f1 100644 --- a/completions/glsa-check +++ b/completions/glsa-check @@ -1,32 +1,31 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # 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 diff --git a/completions/java-config b/completions/java-config index 42bf11e..a551e44 100644 --- a/completions/java-config +++ b/completions/java-config @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # diff --git a/completions/layman b/completions/layman index 81811b0..e5441ac 100644 --- a/completions/layman +++ b/completions/layman @@ -2,7 +2,7 @@ # # $Id$ # -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2012 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # # Originally licensed as 'public-domain' @@ -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 diff --git a/completions/metagen b/completions/metagen index 3ba0dc9..90f4996 100644 --- a/completions/metagen +++ b/completions/metagen @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later _metagen() { 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 diff --git a/completions/portageq b/completions/portageq index 7922e59..ed0f69a 100644 --- a/completions/portageq +++ b/completions/portageq @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" @@ -47,8 +47,8 @@ _portageq() { # 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})) + COMPREPLY=($(compgen -W "$(env -i PATH="${PATH}" emerge -v --info | \ + cut -s -d = -f 1)" -- ${cur})) ;; *v@(isible|ersion)|match) 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 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 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 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 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 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 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 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 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 diff --git a/completions/repoman b/completions/repoman index b9dac93..d8b00db 100644 --- a/completions/repoman +++ b/completions/repoman @@ -2,7 +2,7 @@ # # $Id$ # -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2012 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # repoman completion by Jeremy Olexa <darkside@gentoo.org> diff --git a/completions/revdep-rebuild b/completions/revdep-rebuild index cb0efe7..e8520b8 100644 --- a/completions/revdep-rebuild +++ b/completions/revdep-rebuild @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later _revdep_rebuild() { diff --git a/completions/splat b/completions/splat index ddae6a0..4ae1d3e 100644 --- a/completions/splat +++ b/completions/splat @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later source "@helpersdir@/gentoo-common.sh" diff --git a/completions/webapp-config b/completions/webapp-config index 01679b5..8867a7f 100644 --- a/completions/webapp-config +++ b/completions/webapp-config @@ -1,6 +1,6 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2013 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # |