diff --git a/_baselayout b/_baselayout new file mode 100644 index 0000000..84faf08 --- /dev/null +++ b/_baselayout @@ -0,0 +1,160 @@ +#compdef rc-update rc-status rc rc-service +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Gentoo Baselayout v2 and OpenRC v0.8 (init system). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Unknown Person +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +# +# +# Status: +# rc (fully done) +# rc-update (fully done) +# rc-status (fully done) +# rc-service (to be improved) + + +local gentoo_runlevels +gentoo_runlevels=(/etc/runlevels/*(:t)) + + +# Stuff for rc +_rc () { + if (( CURRENT == 2 )); then + _values 'runlevels' $gentoo_runlevels + fi +} + +_rc_list_service () { + local servicelist + servicelist=(${(f)"$(/sbin/rc-service -Cl 2>/dev/null)"}) + _values 'services' $servicelist +} +# Stuff for rc-service +_rc-service () { + servicelist=${(f)"$(/sbin/rc-service -Cl 2>/dev/null)"} + if (( CURRENT == 2 ));then + _arguments -s \ + '(-e --exists)'{-e,--exists}"[tests if the service exists or not]" \ + '(-l --list)'{-l,--list}'[list all available services]' \ + '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \ + '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \ + '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \ + '(-q --quiet)'{-q,--quiet}'[Run quietly]' + _rc_list_service + else + case $words[2] in + -e|--exists|-r|--resolve) + (( CURRENT > 3 )) && return 0 + _rc_list_service + ;; + -*) + return 0 + ;; + *) + _values "action" stop start restart describe zap + ;; + esac + fi +} + +# Stuff for rc-status +_rc-status () { + _arguments -s \ + '(-a --all)'{-a,--all}'[Show services at all run levels]' \ + '(-l --list)'{-l,--list}'[Show list of run levels]' \ + '(-nc --nocolor)'{-nc,--nocolor}'[Disable color output]' \ + '(-s --servicelist)'{-s,--servicelist}'[Show all services]' \ + '(-u --unused)'{-u,--unused}'[Show services not assigned to any run level]' + + _values 'runlevels' $gentoo_runlevels +} + + +# Stuff for rc-update +_rc-update () { + local used_init + + # FIXME: ${=${(f)"$(rc-update show 2>/dev/null)"}% |*} yield the same result (for me). + # we probably don't need any more the (M) matcher part. + used_init=(${=${(M)${(f)"$(/sbin/rc-update show 2>/dev/null)"}:#*|*[a-z]*}% |*}) + + if (( CURRENT == 2 )); then + _values 'rc-update actions' \ + 'add[Add script to a runlevel]' \ + 'del[Delete script from a runlevel]' \ + 'show[Show scripts lanched at a runlevel]' \ + '-a[Add script to a runlevel]' \ + '-d[Delete script from a runlevel]' \ + '-s[Show scripts lanched at a runlevel]' + elif (( CURRENT == 3 )); then + case "$words[2]" in + add|-a) + _values 'scripts' /etc/init.d/*~*.sh(:t) + ;; + del|-d) + _values 'scripts' $used_init + ;; + show|-s) + _values 'runlevels' $gentoo_runlevels \ + '-v[Show all init scripts]' \ + '--verbose[Show all init scripts]' + ;; + esac + elif (( CURRENT == 4 )); then + _values 'runlevels' $gentoo_runlevels + fi +} + + +case "$service" in + rc-update) + _rc-update "$@" && return 0 + ;; + rc-service) + _rc-service "$@" && return 0 + ;; + rc-status) + _rc-status "$@" && return 0 + ;; + rc) + _rc "$@" && return 0 + ;; +esac diff --git a/_eselect b/_eselect new file mode 100644 index 0000000..b9fa322 --- /dev/null +++ b/_eselect @@ -0,0 +1,199 @@ +#compdef eselect +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Eselect (symlink manager for multiversioning +# and multibranding support for some libraries and binaries). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Unknown Person +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +# +# + + +_eselect_env () { + if (( $words[(I)(update)] )); then + _values 'update options' \ + 'makelinks[force updating of links]' \ + 'noldconfig[Do not alter the ld.so cache or configuration]' && return 0 + fi + _values 'env options' $stdopts[@] \ + 'update[Collect environment variables from all scripts]' && return 0 +} + +_eselect_binutils () { + local binutilslist + if (( $words[(I)(set)] )); then + binutilslist=(${${${(M)${(f)"$(eselect --no-color binutils list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values 'available binutils version' $binutilslist[@] && return 0 + fi + _values 'binutils options' $stdopts[@] \ + 'list[List all installed version of binutils]' \ + 'show[Print the currently active binutils version]' \ + 'set[Activate one of the installed binutils]' && return 0 +} + +_eselect_kernel () { + local kernellist + if (( $words[(I)(set)] )); then + kernellist=(${${${(M)${(f)"$(eselect --no-color kernel list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values 'available kernel version' $kernellist[@] && return 0 + fi + _values 'kenrel options' $stdopts[@] \ + 'list[List available kernel symlink targets]' \ + 'show[Show the current kernel symlink]' \ + 'set[Set a new kernel symlink target]' && return 0 +} +_eselect_ctags () { + local ctagslist + if (( $words[(I)(set)] )); then + ctagslist=(${${${(M)${(f)"$(eselect --no-color ctags list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values 'available ctags version' $ctagslist[@] && return 0 + fi + _values 'ctags options' $stdopts[@] \ + 'list[List available ctags symlink targets]' \ + 'show[Show the current target of the ctags symlink]' \ + 'update[Automatically update the ctags symlink]' \ + 'set[Set a new ctags symlink target]' && return 0 +} +_eselect_profile () { + local profilelist + if (( $words[(I)(set)] )); then + profilelist=(${${${(M)${(f)"$(eselect --no-color profile list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values -w 'available profiles' $profilelist[@] \ + '--force[Forcibly set the symlink]' && return 0 + fi + _values 'profile options' $stdopts[@] \ + 'list[List available profile symlink targets]' \ + 'show[Show the current make.profile symlink]' \ + 'set[Set a new profile symlink target]' && return 0 +} +_eselect_fontconfig () { + local fclistenabled fclistdisabled + if (( $words[(I)(enable)] )); then + fclistdisabled=(${${${${(M)${(f)"$(eselect --no-color fontconfig list)"}## *}#*\*}// \**/}//( \[*\] | \[*\] )/}) + _values -w '.conf to enable' $fclistdisabled[@] && return 0 + elif (( $words[(I)(disable)] )); then + fclistenabled=(${${${(M)${(M)${(f)"$(eselect --no-color fontconfig list)"}## *}#*\*}// \**/}//( \[*\] | \[*\] )/}) + _values -w '.conf to disable' $fclistenabled[@] && return 0 + fi + _values 'fontconfig options' $stdopts[@] \ + 'list[List available fontconfig .conf files]' \ + 'disable[Disable specified fontconfig .conf file(s)]' \ + 'enable[Enable specified fontconfig .conf file(s)]' && return 0 +} +_eselect_opengl () { + local opengllist + if (( $words[(I)(set)] )); then + opengllist=(${${${(M)${(f)"$(eselect --no-color opengl list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values -w 'opengl implementations and options' $opengllist[@] \ + '--use-old[If an implementationis already set, use that one instead]' \ + '--prefix[Set the source prefix]:path:_files -/' \ + '--dst-prefix[Set the destination prefix]:path:_files -/' \ + '--impl-headers[Override global headers with ones provided by this profile]' && return 0 + fi + _values 'opengl options' $stdopts[@] \ + 'list[List the available OpenGL implementations]' \ + 'set[Select the OpenGL implementation]' \ + 'show[Print the current OpenGL implementation]' && return 0 +} +_eselect_vi () { + local vilist + if (( $words[(I)(set)] )); then + vilist=(${${${(M)${(f)"$(eselect --no-color vi list)"}## *}// \**/}//( \[*\] | \[*\] )/}) + _values -w 'vi implementation' $vilist[@] && return 0 + elif (( $words[(I)(update)] )); then + _values -w 'option' '--if-unset[Do not override existing implementation]' && return 0 + fi + _values 'vi options' $stdopts[@] \ + 'list[List available vi implementations]' \ + 'set[Set a new vi implementation provider]' \ + 'show[Show the current vi implementation]' \ + 'update[Automatically update the vi provider]' && return 0 +} +_eselect () { + local globopts sedcmd modnames modopts + local stdopts + stdopts=( + 'help[Display help text]' + 'usage[Display usage information]' + 'version[Display version information]' + ) + globopts=( + '--no-colour[Disable coloured output]' + '--no-color[Disable coloured output]' + ) + modnames=(${${${(M)${(f)"$(eselect --no-color list-modules)"}## *}// */}// /}) + if ((CURRENT == 2)); then + _arguments -s \ + "$globopts[@]" \ + "*:portage:_values 'eselect modules' \$modnames[@]" && return 0 + elif ((CURRENT == 3)); then + if [[ $words[2] == --no-colour || $words[2] == --no-color ]]; then + _arguments -s \ + "*:portage:_values 'eselect modules' \$modnames[@]" && return 0 + elif (( $modnames[(I)$words[2]] )); then + if [[ "$words[2]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi) ]]; then + _eselect_$words[2] "$@" + else + modopts=(${${${(M)${(f)"$(eselect --no-color $words[2] usage)"}## *}// */}// /}) + _arguments -s \ + "*:portage:_values 'eselect $words[2] options' \$modopts[@]" && return 0 + fi + fi + elif ((CURRENT >= 4)); then + if (( $words[(I)(--no-color|--no-colour)] )); then + if (( $modnames[(I)$words[3]] )); then + if [[ "$words[3]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi) ]]; then + _eselect_$words[3] "$@" + else + modopts=(${${${${(M)${(f)"$(eselect --no-color $words[3] usage)"}## *}// */}// /}// *}) + _arguments -s \ + "*:portage:_values 'eselect $words[3] options' \$modopts[@]" && return 0 + fi + fi + else + if (( $modnames[(I)$words[2]] )); then + _eselect_$words[2] "$@" + fi + fi + fi +} + +_eselect "$@" \ No newline at end of file diff --git a/_gcc-config b/_gcc-config new file mode 100644 index 0000000..508c101 --- /dev/null +++ b/_gcc-config @@ -0,0 +1,70 @@ +#compdef gcc-config +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for GCC config script (symlink manager for multiversioning). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * oberyno +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +# + +local arguments + +arguments=( + '(- :)'{--use-old,-O}'[use the old profile if one was selected]' + '(- :)'{--use-portage-chost,-P}'[only set profile if its CHOST matches /etc/make.conf]:profiles:_gcc_profile' + '(- :)'{--get-current-profile,-c}'[print current used gcc profile]' + '(- :)'{--list-profiles,-l}'[print a list of available profiles]' + '(- :)'{--print-environ,-E}'[print environment of the given/current profile]:profiles:_gcc_profile' + '(- :)'{--get-bin-path,-B}'[print binary path of given/current profile]:profiles:_gcc_profile' + '(- :)'{--get-lib-path,-L}'[print library path of given/current profile]:profiles:_gcc_profile' + '(- :)'{--get-stdcxx-incdir,-X}'[print g++ include path of given/current profile]:profiles:_gcc_profile' + '(- :)'{--help,-h}'[show help]' + '(- :)'{--version,-v}'[show version info]' + '(- :):profiles:_gcc_profile' +) + +_gcc_profile () { + local profile + profile=(${(f)"$(_call_program gcc-installed RC_NOCOLOR=yes gcc-config --list-profiles)"}) + profile=${${profile/\[([^]]*)\]/}/\*} + _tags profile && { compadd "$@" -k profile || compadd "$@" ${(kv)=profile} } +} + +_arguments $arguments \ No newline at end of file diff --git a/_genlop b/_genlop new file mode 100644 index 0000000..9cb8c2d --- /dev/null +++ b/_genlop @@ -0,0 +1,147 @@ +#compdef genlop +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for GenLop (Gentoo Installation log parser). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Unknown Person +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +# + + +_genlop () { +local prev1="$words[CURRENT-1]" prev2="$words[CURRENT-2]" days months arg single state lstate +days=(monday tuesday wednesday thursday friday saturday sunday) +months=(january february march april may june july august september october november december) +arg=( --current -c --time -t --gmt -g --info -i --file -f --rsync -r --unmerge -u --date --search -s --list -l ) +single=( --current -c --pretend -p --help -h --version -v ) + + [[ ${prev2} == (1st|2nd|3rd|4th|5th) ]] && + compadd in\ $months && return 0 + [[ ${prev1} == ([2-9]|[1-9][0-9]*) && ${prev2} != \ + (january|february|march|april|may|june|july|august|september|october|november|december) ]] && + _values '' 'days ago' 'months ago' 'years ago' 'weeks ago' && return 0 + [[ ${prev1} == (1) && ${prev2} != \ + (january|february|march|april|may|june|july|august|september|october|november|december) ]] && + _values '' 'day ago' 'month ago' 'year ago' 'week ago' && return 0 + + case "$prev1" in + last) + _values '' month week + compadd $days && return 0 + ;; + 1st|2nd|3rd|4th|5th) + compadd $days && return 0 + ;; + january|february|march|april|may|june|july|august|september|october|november|december) + compadd {1..31} && return 0 + ;; + --date) + _message 'enter number for more options or use mm/dd/yyyy format' + _values '' \ + last yesterday 1st 2nd 3rd 4th 5th + _alternative \ + '*:*:_days' '*:*:_months' && return 0 + ;; + --file|-f) + _arguments '*:logfile:_files' && return 0 + ;; + *) + _arguments \ + "($single $arg *)"{--current,-c}"[display the current merge in action]" \ + "($single)*--date[specify date of event]:date:->date" \ + "($single)*-f[specify the logfile to use]:logfile:_files" \ + "($single --gmt -g)"{--gmt,-g}"[display time in GMT/UTC format (default is local time)]" \ + "($single $arg *)"{--help,-h}"[display help information]" \ + "($single --info -i --list -l)"{--info,-i}"[print brief summary about installed ebuild]" \ + "($single --search -s --info -i --list -l *)"{--list,-l}"[list merge history]" \ + "(--nocolor -n)"{--nocolor,-n}"[disable colored output]" \ + "($single $arg *)"{--pretend,-p}"[estimate build time of a piped emerge -p]" \ + "($single --search -s --info -i --time -t --unmerge -u --rsync -r *)"{--rsync,-r}"[display rsync history]" \ + "($single --rsync -r --search -s --list -l *)"{--search,-s}"[select ebuilds matching the provided regular expression]:pattern:" \ + "($single --time -t)"{--time,-t}"[display merge time]" \ + "($single --rsync -r --unmerge -u)"{--unmerge,-u}"[display when packages have been unmerged]" \ + "($single $arg *)"{--version,-v}"[display version information]" \ + "($single)*:package:_gentoo_packages available" + ;; + esac + + while [[ -n "$state" ]]; do + lstate=$state + state='' + case "$lstate" in + date) _message 'enter number for more options or use mm/dd/yyyy format' + _values '' \ + last yesterday 1st 2nd 3rd 4th 5th + _alternative \ + ':*:_days' ':*:_months' && return 0 + ;; + esac + done +} + +_days() { + local m="monday" t="tuesday" w="wednesday" T="thursday" f="friday" s="saturday" S="sunday" + local day=$(date +%u) + if [[ ${day} == 1 ]] then compadd $m + elif [[ ${day} == 2 ]] then compadd $m $t + elif [[ ${day} == 3 ]] then compadd $m $t $w + elif [[ ${day} == 4 ]] then compadd $m $t $w $T + elif [[ ${day} == 5 ]] then compadd $m $t $w $T $f + elif [[ ${day} == 6 ]] then compadd $m $t $w $T $f $s + elif [[ ${day} == 7 ]] then compadd $m $t $w $T $f $s $S + fi +} +_months() { + local j="january" f="february" m="march" a="april" M="may" ju="june" J="july" A="august" s="september" o="october" n="november" d="december" + local month=$(date +%m) + if [[ ${month} == 01 ]] then compadd $j + elif [[ ${month} == 02 ]] then compadd $j $f + elif [[ ${month} == 03 ]] then compadd $j $f $m + elif [[ ${month} == 04 ]] then compadd $j $f $m $a + elif [[ ${month} == 05 ]] then compadd $j $f $m $a $M + elif [[ ${month} == 06 ]] then compadd $j $f $m $a $M $ju + elif [[ ${month} == 07 ]] then compadd $j $f $m $a $M $ju $J + elif [[ ${month} == 08 ]] then compadd $j $f $m $a $M $ju $J $A + elif [[ ${month} == 09 ]] then compadd $j $f $m $a $M $ju $J $A $s + elif [[ ${month} == 10 ]] then compadd $j $f $m $a $M $ju $J $A $s $o + elif [[ ${month} == 11 ]] then compadd $j $f $m $a $M $ju $J $A $s $o $n + elif [[ ${month} == 12 ]] then compadd $j $f $m $a $M $ju $J $A $s $o $n $d + fi +} diff --git a/_gentoo_packages b/_gentoo_packages new file mode 100644 index 0000000..3165394 --- /dev/null +++ b/_gentoo_packages @@ -0,0 +1,221 @@ +#autoload +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# functions for gentoo packages +# inspired by _deb_packages +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Unknown Person +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +#Usage: _gentoo_packages installed|available|installed_versions|available_versions|binary|category|useflag|overlays|sets|licenses + +# List installed overlays +_gentoo_packages_overlays () { + for f in /etc/make.conf /etc/make.globals; do + [[ -z "$PORTDIR_OVERLAY" && -r "$f" ]] && + local PORTDIR_OVERLAY="`. "$f" 2>/dev/null; echo ${PORTDIR_OVERLAY}`" + done + compadd $=PORTDIR_OVERLAY +} + +#List the sets +_gentoo_packages_sets() { + local sets + [[ -f /usr/share/portage/config/sets.conf ]] && sets=(${${${(M)${(f)"$(, and _path_files wants to + # complete cat/pkg/files (if "files" is ignored with -F, miscfiles, etc... + # don't get completed). + if [[ $PREFIX != */* ]] ; then + _wanted cat_packages expl 'category/package' compadd -S '/' $category + else + compset -P '*/' + pkg=( $trees/$IPREFIX/*(:t) ) + _wanted cat_packages expl 'category/package' compadd $pkg + fi +} + +_gentoo_packages_available_versions(){ + local var overlay_ebuilds portage_ebuilds expl trees category + + for var in PORTDIR PORTDIR_OVERLAY ; do + [[ -z ${(P)var} && -r /etc/make.conf ]] && + local $var="`. /etc/make.conf 2>/dev/null; echo ${(P)var}`" + [[ -z ${(P)var} && -r /etc/make.globals ]] && + local $var="`. /etc/make.globals 2>/dev/null; echo ${(P)var}`" + done + trees=($PORTDIR $=PORTDIR_OVERLAY) + category=( $trees/*-*(/:t) ) + typeset -U category + + if [[ $#PREFIX -ge 1 && -z $words[(r)(--inject|-i)] ]] ; then + overlay_ebuilds=($=PORTDIR_OVERLAY/*-*/${PREFIX%%-[0-9]#*}*/*.ebuild(:t:r) ) + portage_ebuilds=($PORTDIR/metadata/cache/*-*/${PREFIX%%-[0-9]#*}*(:t)) + _wanted packages expl 'package' compadd $portage_ebuilds $overlay_ebuilds + fi + pkg=( $trees/${PREFIX%%/*}/*/*.ebuild(:t:r) ) + _wanted cat_packages expl 'category/package' _sep_parts category / pkg +} + +#Function to show tbz2 files available +_gentoo_packages_binary() { + [[ -z $PKGDIR && -r /etc/make.conf ]] && + local PKGDIR="`. /etc/make.conf 2>/dev/null; echo $PKGDIR`" + [[ -z $PKGDIR && -r /etc/make.globals ]] && + local PKGDIR="`. /etc/make.globals 2>/dev/null; echo $PKGDIR`" + + # this doesn't take care of ${PORTAGE_BINHOST}. If Gentoo official + # binary mirror will be available we should rewrite it accordingly. + _path_files -g \*.tbz2 -W "$PKGDIR/All" +} + +_gentoo_packages () { + local command="$argv[$#]" + [[ "$command" == (sets|licenses|installed(_versions|)|available(_versions|)|binary|category|(active_|)useflag|available_pkgnames_only|overlays) ]] || { + _message "unknown command: $command" + return 1 + } + _gentoo_packages_$command +} + +_gentoo_packages "$@" diff --git a/_gentoolkit b/_gentoolkit new file mode 100644 index 0000000..1578196 --- /dev/null +++ b/_gentoolkit @@ -0,0 +1,402 @@ +#compdef equery euse eclean eclean-dist eclean-pkg epkginfo genpkgindex glsa-check revdep-rebuild +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for Gentoolkit (collection of Gentoo administrative scripts). +# (Means portage helper python-scrips and some usefull staff) +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Unknown Preson +# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode +# * Vadim A. Misbakh-Soloviev +# +# ------------------------------------------------------------------------------ +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------ +# +# +# Status: +# euse (fully done) +# equery (fully done) +# eclean* (fully done) +# epkginfo (fully done) +# genpkgindex (fully done) +# glsa-check (fully done) +# revdep-rebuild (fully done) +# eread (nothing todo) + + +# XXX: shouldn't this go to _gentoo_package? +_packages () { + if compset -P '(\\|)(>=|<=|<|>|=)' ; then + _gentoo_packages ${*/(#m)(installed|available)/${MATCH}_versions} + else + _gentoo_packages $* + fi +} + + +_euse () { + local state tmp start_args suboptions_args + start_args=( + {'(--help)-h','(-h)--help'}'[show help]' + {'(--version)-v','(-v)--version'}'[show version]' + {'(--info)-i','(-i)--info'}'[show descriptions for the given useflags]' + {'(--active)-a','(-a)--active'}'[show currently active useflags and their origin]' + {'(--enable)-E','(-E)--enable'}'[enable the given useflags]' + {'(--disable)-D','(-D)--disable'}'[disable the given useflags]' + {'(--prune)-P','(-P)--prune'}'[show version]' + ) + suboptions_args=( + {'(--global)-g','(-g)--global'}'[show only global use flags]' + {'(--local)-l','(-l)--local'}'[show only local use flags]' + ) + if (( CURRENT == 2 ));then + _arguments -s $start_args + elif (( CURRENT == 3 ));then + case "$words[2]" in + -i|--info|-a|--active) + _arguments -s $suboptions_args \ + '*:useflags:_gentoo_packages useflag' && ret=0 + ;; + -E|--enable) + _arguments \ + '*:useflags:_gentoo_packages useflag' && ret=0 + ;; + -D|--disable) + _arguments \ + '*:active useflags:_gentoo_packages active_useflag' && ret=0 + esac + else + _arguments \ + '*:useflag:_gentoo_packages useflag' && ret=0 + fi +} + + +_equery () { + # Based off of X/_xauth. + local state context line expl ret=1 + local tmp cmd start_args common_args + + start_args=( + {'(--nocolor)-C','(-C)--nocolor'}'[turns off colors]' + {'(--quiet)-q','(-q)--quiet'}'[minimal output]' + {'(--help)-h','(-h)--help'}'[show help]' + {'(--version)-V','(-V)--version'}'[show version]' + ) + + common_args=( + '(-i --installed -I --exclude-installed)'{-i,--installed}'[search installed packages]' + '(-I --exclude-installed -i --installed)'{-I,--exclude-installed}'[do not search installed packages]' + '(-p --portage)'{-p,--portage-tree}'[also search in portage tree]' + '(-o --overlay-tree)'{-o,--overlay-tree}'[also search in overlay tree]' + ) + + + _arguments -s $start_args \ + '*::command:->command' && ret=0 + + while [[ -n "$state" ]]; do + tmp="$state" + state= + case "$tmp" in + command) + if (( CURRENT == 1 )); then + state=subcommands + else + cmd="$words[1]" + curcontext="${curcontext%:*:*}:equery-${cmd}:" + case "$cmd" in + belongs|b) + _arguments \ + '(-c --category)'{-c,--category}'[only search in specified category]:category:_gentoo_packages category' \ + '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ + '(-f --full-regex)'{-f,--full-regex}'[supplied query is a full regex]:pattern:' \ + '*:file:_files' && ret=0 + ;; + check|k) + _arguments \ + ':portage:_packages installed' && ret=0 + ;; + depends|d) + _arguments \ + '(-a --all-packages)'{-a,--all-packages}'[search in all available packages (slow)]:all packages:->packages' \ + '(-d --direct -D --indirect)'{-d,--direct}'[search direct dependencies only (default)]' \ + '(-d --direct -D --indirect)'{-D,--indirect}'[search indirect dependencies (VERY slow)]' \ + '*:package:_packages installed' && ret=0 + ;; + depgraph|g) + _arguments \ + '(-U --no-useflags)'{-U,--no-useflags}'[do not show USE flags]' \ + '(-l --linear)'{-l,--linear}'[do not use fancy formatting]' \ + ':package:_packages installed' && ret=0 + ;; + files|f) + _arguments \ + '--timestamp[append timestamp]' \ + '--md5sum[append md5sum]' \ + '--type[prepend file type]' \ + '--filter=[filter output]:filter(s):_values -s , '' dir obj sym dev fifo path conf cmd doc man info' \ + ':installed pkgname:_packages installed' && ret=0 + ;; + hasuse|h) + _arguments \ + $common_args \ + ':useflag:_gentoo_packages useflag' && ret=0 + ;; + list|l) + _arguments \ + $common_args \ + ': :_guard "^--*" pattern' && ret=0 + ;; + size|s) + _arguments \ + '(-b --bytes)'{-b,--bytes}'[report size in bytes]' \ + ':package:_packages installed' && ret=0 + ;; + which|w) + _arguments \ + ':portage:_packages available' && ret=0 + ;; + uses|u) + _arguments \ + {--all,-a}'[include non-installed packages]' \ + ":portage:_packages installed" && ret=0 + ;; + *) + _message 'command not found' + ;; + esac + fi + ;; + subcommands) + tmp=( + {belongs,b}'[list all packages owning file(s)]' + {check,k}'[check MD5sums and timestamps of package]' + {depends,d}'[list all packages depending on specified package]' + {depgraph,g}'[display a dependency tree for package]' + {files,f}'[list files owned by package]' + {hasuse,h}'[list all packages with specified useflag]' + {list,l}'[list all packages matching pattern]' + {size,s}'[print size of files contained in package]' + {uses,u}'[display USE flags for package]' + {which,w}'[print full path to ebuild for package]' + ) + _values 'equery command' $tmp && ret=0 + ;; + esac + done +} + + +_eclean_wrapper () { + local global_opts pkg_opts dist_opts + + global_opts=( + '(-C --nocolor)'{-C,--nocolor}'[turns off colors]' + '(-d,--destructive)'{-d,--destructive}'[only keep the minimum for a reinstallation]' + '(-e,--exclude-file)'{-e,--exclude-file}'[path to the exclusion file]:filename:_files' + '(-i,--interactive)'{-i,--interactive}'[ask confirmation before deletions]' + '(-n,--package-names)'{-n,--package-names}'[protect all versions (when --destructive)]' + '(-p,--pretend)'{-p,--pretend}'[only display what would be cleaned]' + '(-q,--quiet)'{-q,--quiet}'[minimal output]' + '(-t,--time-limit)'{-t,--time-limit}'[don’t delete files modified since