Some Gentoo-related completions

This commit is contained in:
Vadim A. Misbakh-Soloviev 2011-10-16 23:51:35 +07:00
parent 25a9524e9b
commit 465e763f77
9 changed files with 1829 additions and 0 deletions

160
_baselayout Normal file
View File

@ -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 <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<sys-apps/baselayout-1.12.11.1>
#
# 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

199
_eselect Normal file
View File

@ -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 <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<app-admin/eselect-1.0.11>
#
_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 "$@"

70
_gcc-config Normal file
View File

@ -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 <oberyno@gmail.com>
# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode
# * Vadim A. Misbakh-Soloviev <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<sys-devel/gcc-config-0.0>
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

147
_genlop Normal file
View File

@ -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 <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<app-portage/genlop-0.30.8>
_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
}

221
_gentoo_packages Normal file
View File

@ -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 <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- 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)"$(</usr/share/portage/config/sets.conf)"}##\[*}/\[/@}/\]})
[[ -f /etc/portage/sets.conf ]] && sets=($sets ${${${(M)${(f)"$(</etc/portage/sets.conf)"}##\[*}/\[/@}/\]})
compadd $sets
}
#List licenses
_gentoo_packages_licenses () {
local licenses var PORTDIR
var=PORTDIR
[[ -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}`"
licenses=($PORTDIR/licenses/*(:t))
compadd $licenses
}
# Completion function to show useflags.
_gentoo_packages_useflag(){
local flags var PORTDIR
var=PORTDIR
[[ -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}`"
flags=( ${${(M)${(f)"$(<$PORTDIR/profiles/use.desc)"}:#* - *}%% - *}
${${${(M)${(f)"$(<$PORTDIR/profiles/use.local.desc)"}#* - *}%% - *}#*:} )
compadd $flags
}
_gentoo_packages_active_useflag(){
local flags var USE
var=USE
[[ -z ${(P)var} && -r /etc/make.conf ]] &&
local $var="`. /etc/make.conf 2>/dev/null; echo ${(P)var}`"
flags=(${${${=USE}%-*}%\\*})
compadd $flags
}
_gentoo_packages_category(){
local var 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) )
_wanted cat_packages expl 'category' compadd "$@" $category
}
_gentoo_packages_installed(){
local installed_dir installed_portage installed_list expl
installed_dir="/var/db/pkg"
installed_portage=($installed_dir/*-*/*)
installed_pkgname=( ${${installed_portage:t}%%-[0-9]*} )
_wanted packages expl 'category/package' compadd "$@" ${installed_pkgname}
installed_list=( ${${installed_portage#$installed_dir/}%%-[0-9]*} )
_wanted cat_packages expl 'category/package' _multi_parts "$@" / installed_list
}
_gentoo_packages_installed_versions(){
local installed_list installed_portage expl
installed_portage=(/var/db/pkg/*-*/*)
_wanted packages expl 'package' compadd "$@" ${installed_portage:t}
installed_list=( ${installed_portage##*/pkg/} )
_wanted cat_packages expl 'category/package' _multi_parts "$@" / installed_list
}
_gentoo_packages_available_pkgnames_only(){
local var trees packages
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)
packages=( $trees/*-*/*(:t) )
_wanted packages expl 'package' compadd - "${(@)packages}"
}
_gentoo_packages_available(){
local var trees category packages pkg expl
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) )
packages=( $trees/*-*/*(:t) )
_wanted packages expl 'package' compadd - "${(@)packages}"
# Complete cat/pkg. _multi_parts is much to slow for such a large task,
# _sep_parts removes the dash from gnome-<tab>, 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 "$@"

402
_gentoolkit Normal file
View File

@ -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 <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<app-portage/gentoolkit-0.2.4-rc3>
#
# 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}'[dont delete files modified since <time>]:time:_eclean_time'
'(: -)'{-h,--help}'[show help]'
'(: -)'{-V,--version}'[show version]'
)
dist_opts=(
'(-s,--size-limit)'{-s,--size-limit}'[do not delete disfiles bigger than <size>]:size:_eclean_size'
'(-f,--fetch-restricted)'{-f,--fetch-restricted}'[protect fetch-restricted files]'
)
# XXX: If you add options here make sure that it'll work.
# since there isn't any option *right* now, $pkg_opts
# is never used.
pkg_opts=()
# check which kind of eclean command we run.
case "$words[1]" in
eclean-pkg)
_arguments -s $global_opts $pkg_opts &&
return 0
;;
eclean-dist)
_arguments -s $global_opts $dist_opts &&
return 0
;;
eclean)
# eclean. complete only specifics options if an action has been given,
# global_opts and packages|distfiles otherwhise.
if (( $words[(I)(packages)] )); then
# Currently no options so return 0
#_values "packages options" $pkg_opts &&
return 0
elif (( $words[(I)(distfiles)] )); then
_values "distfiles options" $dist_opts &&
return 0
else
_arguments -s $global_opts
# complete packages|distfiles only if CURRENT-1 don't need an arg
if [[ ! $words[CURRENT-1] =~ -(e|-exclude-file|t|-time-limit|s|-size-limit|h|-help|v|-version) ]]; then
_values 'eclean command' \
'packages[clean outdated binary packages]' \
'distfiles[clean outdated packages sources files]' &&
return 0
fi
fi
;;
esac
}
_eclean_time () {
# adapted from _chmod
compset -P '*'
suf=( -S '' )
_alternative -O suf \
'number:number:(0 1 2 3 4 5 6 7 8 9)' \
'time_unit:time_unit:((y\:year m\:month w\:week d\:day h\:hour))' &&
return 0
}
_eclean_size () {
# adapted from _chmod
compset -P '*'
suf=( -S '' )
_alternative -O suf \
'number:number:(0 1 2 3 4 5 6 7 8 9)' \
'time_unit:time_unit:((G\:gigabytes M\:megabytes K\:kilobytes B\:bytes))' &&
return 0
}
_epkginfo () {
if (( CURRENT == 2 )); then
_arguments -s '*:package:_gentoo_packages available'
fi
}
_genpkgindex () {
_arguments -s \
'(: -)'{-h,--help}'[Display help and exit]' \
'(-h --help -q --quiet -v --verbose)'{-q,--quiet}'[Be quiet]' \
'(-h --help -q --quiet -v --verbose)'{-v,--verbose}'[Be verbose]' \
'(-h --help -c --compress)'{-c,--compress}'[Compresses the generated metadata with bzip2]' \
'(-h --help -P --pkgdir)'{-P,--pkgdir}'[Set the base location of the binary packages (default $PKGDIR)]:file:_files'
}
_glsa-check () {
local actions
actions=(-l --list -d --dump --print -t --test -p --pretend -f --fix -i --inject -h --help -V --version -m --mail)
_arguments -s \
"($actions)"{-l,--list}'[list all unapplied GLSA]:glsa_id:_glsa_id' \
"($actions)"{-d,--dump,--print}'[show all information about the given GLSA]:glsa_id:_glsa_id' \
"($actions)"{-t,--test}'[test if this system is affected by the given GLSA]:glsa_id:_glsa_id' \
"($actions)"{-p,--pretend}'[show the necessary commands to apply this GLSA]:glsa_id:_glsa_id' \
"($actions)"{-f,--fix}'[try to auto-apply this GLSA (experimental)]:glsa_id:_glsa_id' \
"($actions)"{-i,--inject}'[inject the given GLSA into the checkfile]:glsa_id:_glsa_id' \
'(-n --nocolor)'{-n,--nocolor}'[disable colors (option)]' \
'(: -)'{-h,--help}'[Show help message]' \
'(: -)'{-V,--version}'[some information about this tool]' \
'(-v --verbose)'{-v,--verbose}'[print more messages (option)]' \
'(-c --cve)'{-c,--cve}'[show CAN ids in listing mode (option)]' \
"($actions)"{-m,--mail}'[send a mail with the given GLSAs to the administrator]:glsa_id:_glsa_id'
}
# glsa-list can contain an arbitrary number of GLSA ids,
# filenames containing GLSAs or the special identifiers
# 'all', 'new' and 'affected'
_glsa_id () {
# XXX: we'll avoid displaying GLSA ids, because the ratio use/noise
# will be low. May be we should display only the X previous GLSA,
# or GLSA ids of the X last month.
#
# start to look at /usr/lib/gentoolkit/pym/glsa.py if GLSA_DIR is still
# PORTDIR + "metadata/glsa/"
# and then get the list (it's only xml files in GLSA_DIR, easy!)
compadd 'all' 'new' 'affected'
_files
}
_revdep-rebuild () {
if (( $words[(I)(--)] )); then
# here it's no more revdep-rebuild options, but emerge options that are called
_arguments -s '*:portage:_portage --emerge $@' && return 0
fi
_arguments -s \
'(-C --nocolor)'{-C,--nocolor}'[Turn off colored output]' \
'(-d --debug)'{-d,--debug}'[Print way too much information (uses bash set -xv)]' \
'(-e --exact)'{-e,--exact}'[Emerge based on exact package version]' \
'(: -)'{-h,--help}'[Print help]' \
'(-i --ignore)'{-i,--ignore}'[Ignore temporary files from previous runs]' \
'(-k --keep-temp)'{-k,--keep-temp}'[Do not delete temporary files on exit]' \
'(-L --library)'{-L,--library}'[<NAME> Emerge existing packages that use the library with NAME]:file:_files' \
'(-l --no-ld-path)'{-l,--no-ld-path}'[Do not set LD_LIBRARY_PATH]' \
'(-o --no-order)'{-o,--no-order}'[Do not check the build order (Saves time, but may cause breakage)]' \
'(-p --pretend)'{-p,--pretend}'[Do a trial run without actually emerging anything (also passed to emerge command)]' \
'(-P --no-progress)'{-P,--no-progress}'[Turn off the progress meter]' \
'(-q --quiet)'{-q,--quiet}'[Be less verbose (also passed to emerge command)]' \
'(-v --verbose)'{-v,--verbose}'[Be more verbose (also passed to emerge command)]' \
'(-u --no-util)'{-u,--no-util}'[<UTIL> Do not use features provided by UTIL]:file:_files'
# XXX: does someone really use -u|--no-util option?
# we can check packages installed (like portage-utils etc) to see
# which "UTIL" is avaiable.
}
case "$service" in
euse)
_euse "$@" && return 0
;;
equery)
_equery "$@" && return 0
;;
eclean*)
_eclean_wrapper "$@" && return 0
;;
epkginfo)
_epkginfo "$@" && return 0
;;
genpkgindex)
_genpkgindex "$@" && return 0
;;
glsa-check)
_glsa-check "$@" && return 0
;;
revdep-rebuild)
_revdep-rebuild "$@" && return 0
;;
esac

95
_layman Normal file
View File

@ -0,0 +1,95 @@
#compdef layman
# ------------------------------------------------------------------------------
# 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 LayMan (Gentoo overLAYs (repositories) MANager).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Unknown Person
# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode
# * Vadim A. Misbakh-Soloviev <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<app-portage/layman-1.1.1>
#
local arguments actions_args actions global_opts add_actions
_layman_remote_overlays() {
local layman_list_overlays
layman_list_overlays=(${(S)${${(f)"$(layman -k -N -L 2>/dev/null)"}//\[*}#\* })
compadd "$@" ${(kv)=layman_list_overlays} "ALL"
}
_layman_local_overlays() {
local layman_list_overlays
layman_list_overlays=(${(S)${${(f)"$(layman -N -l)"}//\[*}#\* })
compadd "$@" ${(kv)=layman_list_overlays} "ALL"
}
actions=(
--delete -d
--sync -s
--info -i
--sync-all -S
--list -L
--list-local -l
--fetch -f
)
global_opts=(
'(--config -c)'{-c,--config}'[Select an alternative configuration file]:configuration file:_files'
'(--overlays -o)'{-o,--overlays}'[Specifies the location of additional overlay lists]:overlay url:_urls'
'(--nofetch -n)'{-n,--nofetch}'[Prevents from automatically fetching the remote lists of overlays]'
'(--nocheck -k)'{-k,--nocheck}'[Prevents from checking the remote lists of overlays for complete overlay definitions]'
'(--quiet -q)'{-q,--quiet}'[Makes layman completely quiet]'
'(--verbose -v)'{-v,--verbose}'[Verbose output]'
'(--quietness -Q)'{-Q,--quietness}'[Makes layman less verbose]:level:({0..4})'
'(--nocolor -N)'{-N,--nocolor}'[Remove color codes from the output]'
)
add_actions=(
-p --priority
--add -a
)
actions_args=(
"($actions --add -a)"{--add,-a}'[Add the given overlay to your installed overlays]:overlay:_layman_remote_overlays'
"($actions --priority -p)"{--priority,-p}'[It will modify the priority of the added overlay]:priority:({0..100})'
"($actions $add_actions)"{--delete,-d}'[Delete the given overlay from your installed overlays]:overlay:_layman_local_overlays'
"($actions $add_actions)"{--sync,-s}'[Update the specified overlay]:overlat:_layman_local_overlays'
"($actions $add_actions)"{--info,-i}'[Display all available information about the specified overlay]:overlay:_layman_remote_overlays'
"($actions $add_actions)"{--sync-all,-S}'[Update all overlays]'
"($actions $add_actions)"{--list,-L}'[List the contents of the remote list]'
"($actions $add_actions)"{--list-local,-l}'[List the locally installed overlays]'
"($actions $add_actions)"{--fetch,-f}'[Fetches the remote list of overlays]'
)
_arguments $global_opts[@] $actions_args[@]

349
_portage Normal file
View File

@ -0,0 +1,349 @@
#compdef emerge ebuild quickpkg emaint env-update portageq repoman tbz2tool
# ------------------------------------------------------------------------------
# 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 Portage (Gentoo source packages manager) utils.
# TODO: Entropy (binary portage-compatible packages manager) support.
# (equo, entropy-server, administrative scripts)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Unknown Person
# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode
# * Vadim A. Misbakh-Soloviev <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<sys-apps/portage-2.1.4.4>
# TODO: <sys-apps/portage-2.2_aplha*> (sets, some other candies)
#
# Status:
# emerge (fully done)
# ebuild (fully done)
# emaint (fully done)
# env-update (fully done)
# portageq (fully done)
# repoman (fully done)
# tbz2tool (fully done)
# xpak (nothing todo)
# Stuff for ebuild
_ebuild () {
if (( CURRENT == 2 ));then
_files -g \*.ebuild
elif (( CURRENT > 2 ));then
_values "ebuild command" \
'clean[Cleans the temporary build directory]' \
'help[Show help]' \
'setup[Run all package specific setup actions and exotic system checks]' \
'fetch[Fetch all necessary files]' \
'digest[Creates a digest file for the package]' \
'unpack[Extracts the sources to a subdirectory in the build directory]' \
'compile[Compiles the extracted sources by running the src_compile()]' \
'preinst[Run specific actions that need to be done before installation]' \
'install[Installs the package to the temporary install directory]' \
'postinst[Run specific actions that need to be done after installation]' \
'qmerge[Installs the package to the filesystem]' \
'merge[perform the following actions: fetch, unpack, compile, install and qmerge]' \
'unmerge[Remove the installed files of the packages]' \
'prerm[Run specific actions that need to be executed before unmerge]' \
'postrm[Run specific actions that need to be executed after unmerge]' \
'config[Run specific actions needed to be executed after the emerge process has completed]' \
'package[This command is a lot like the merge command, but creates a .tbz2 package instead of installing]' \
'manifest[Updates the manifest file for the package]' \
'rpm[Builds a RedHat RPM package]'
fi
}
# Stuff for quickpkg
_quickpkg () {
if compset -P '(\\|)(>=|<=|<|>|=)'; then
_arguments -s \
'*:installed package:_gentoo_packages installed_versions'
elif compset -P '(\\|)[/]'; then
_path_files -W / -/
else
_arguments \
'*:installed package:_gentoo_packages installed'
fi
}
# Stuff for emerge
_emerge () {
local nopkg_opts all noask_opts bopts install_args common_args profiles
noask_opts=(-p -a --pretend --ask --regen --info --search -s --searchdesc \
-S --version -V --help -h --metadata)
nopkg_opts=(--resume --skipfirst -c --clean -h --help --depclean --info \
--metadata -P --prune --regen -s --search -S --searchdesc --sync -C \
--unmerge -V --version -i --inject)
bopts=($nopkg_opts -b --buildpkg -B --buildpkgonly -G --getbinpkgonly -g \
--getbinpkg -k --usepkg -K --usepkgonly --fetch-all-uri -f -F --fetchonly)
all=($bopts -l --changelog --columns --deep -D --emptytree -e --newuse \
--noconfmem --nodeps -O --noreplace -n --oneshot -1 -o --onlydeps --tree -t \
-u --update -U --upgradeonly)
common_args=(
"($noask_opts --sync)"{-p,--pretend}'[Simply display what would be done]'
"($noask_opts)"{-a,--ask}'[Ask what would be done]'
'(-d --debug --help -h --version -V)'{-d,--debug}'[Tells emerge to run the emerge command in debug mode]'
'(--quiet -q --verbose -v)'{-q,--quiet}'[General outcome is a reduced or condensed output]'
'(--verbose -v --quiet -q)'{-v,--verbose}'[Tell emerge to run in verbose mode]'
'--nospinner[Disables the spinner for the session]'
)
install_args=(
"($bopts)"{-b,--buildpkg}'[Tells emerge to build binary packages]'
"($bopts)"{-B,--buildpkgonly}'[Tells emerge to only build binary packages]'
"($nopkg_opts --emptytree -e -l --changelog --usepkgonly -K)"{-l,--changelog}'[This will show the ChangeLog]'
"($nopkg_opts -t --tree)--columns[Displays versions in aligned format]"
"($nopkg_opts -D --deep)"{-D,--deep}'[Consider the entire dependency tree of packages]'
"($nopkg_opts -e -l --changelog --emptytree)"{-e,--emptytree}'[Only consider glibc as installed packages]'
"($all --nospinner --pretend -p)"{-i,--inject}'[Portage thinks that this package is installed]'
"($nopkg_opts $bopts)"{-f,--fetchonly}'[Just perform fetches for all packages]'
"($nopkg_opts $bopts)"{-F,--fetch-all-uri}'[Fetch all possible files for all packages]'
"($bopts)"{-g,--getbinpkg}'[Tells emerge to download binary package]'
"($bopts)"{-G,--getbinpkgonly}'[As --getbinpkg, but does not use local info]'
"($nopkg_opts)--noconfmem[Causes portage to disregard merge records]"
"($nopkg_opts -O --nodeps)"{-O,--nodeps}'[Merges specified packages without merging dependencies]'
"($nopkg_opts -n --noreplace)"{-n,--noreplace}'[Skip packages already installed]'
"($nopkg_opts)"{-1,--oneshot}'[Do not add package to the world profile]'
"($nopkg_opts --onlydeps -o)"{-o,--onlydeps}'[Only merge (or pretend to merge) the dependencies]'
"($nopkg_opts --columns -t --tree)"{-t,--tree}'[Show dependency tree]'
"($nopkg_opts --update -u)"{-u,--update}'[Updates packages to the most recent version available]'
"($nopkg_opts --upgradeonly -U)"{-U,--upgradeonly}'[Do not update packages to a lower version]'
"($bopts)"{-k,--usepkg}'[Tells emerge to use binary packages if available]'
"($bopts --changelog -l)"{-K,--usepkgonly}'[Tells emerge to use binary packages only]'
"($all)"{-c,--clean}'[Cleans the system by removing packages]'
'(: -)'{-h,--help}'[Displays help]:subject:(sync config system)'
"(: $all)--depclean[Clean all packages that have no reason for being installed]"
"(: $all $noask_opts --nospinner --quiet -q)--info[This is a list of information to include in bug reports]"
'(: -)--metadata[Generate metadata]'
"($nopkg_opts --usepkgonly -K)--newuse[Include installed packages which have changed USE flags]"
"($all)"{-P,--prune}'[Removes all but the latest versions of matching packages]'
"(: $all $noask_opts --verbose -v)--regen[Causes portage to check and update the dependency cache]"
"(: $all $noask_opts --verbose -v)"{-s,--search}'[Searches for matches]'
"(: $all $noask_opts --verbose -v)"{-S,--searchdesc}'[Matches the seachdesc string against the description field]'
"(: $all --pretend -p)--sync[Initiates a portage tree update]"
"($all)"{-C,--unmerge}'[Removes all matching packages]'
'(: -)'{-V,--version}'[Display version info]'
"(: $all[3,-1])--resume[Resumes the last merge operation]"
"(: $all[3,-1])--skipfirst[Removes the first package in the resume list]"
)
profiles=(
'world[All packages in the world profile]'
'system[All packages in the system profile]'
)
# Dispatch
if (( $words[(I)(--(unmerge|clean|prune)|-[[:alpha:]]#(C|c|P)[[:alpha:]]#)] )) ; then
if compset -P '(\\|)(>=|<=|<|>|=)'; then
_arguments -s \
'*:installed package:_gentoo_packages installed_versions' && return 0
else
_arguments -s \
"$common_args[@]" "$install_args[@]" \
"*:installed package:_gentoo_packages installed" && return 0
fi
elif (( $words[(I)(world|system)] )) ; then
_arguments -s \
"$common_args[@]" "$install_args[@]" \
"($nopkg_opts[1,-2] --inject -i --oneshot -1):" && return 0
elif (( $words[(I)(--usepkgonly|-[[:alnum:]]#K[[:alnum:]]#)] )) ; then
_arguments -s \
"$common_args[@]" "$install_args[@]" \
'*:binary package:_gentoo_packages binary' && return 0
elif [[ $words[-3] == (--help|-h) ]] ; then
_message "No more arguments" && return 0
else
if compset -P '(\\|)(>=|<=|<|>|=)'; then
_arguments \
"*:portage:_gentoo_packages available_versions" && return 0
elif (( $words[(I)(--inject|-i)] )) ; then
_arguments -s \
"$common_args[@]" "$install_args[@]" \
"*:portage:_gentoo_packages available_versions" && return 0
else
_arguments -s \
"$common_args[@]" "$install_args[@]" \
"($nopkg_opts)::portage: _values 'profile' \$profiles[@] " \
"($nopkg_opts)::portage:_gentoo_packages sets " \
"($nopkg_opts)*:portage:_gentoo_packages available" && return 0
fi
fi
}
_emaint () {
_arguments -s \
'(: -)'{-h,--help}'[show help message and exit]' \
'(: -)'--version"[show program's version number and exit]" \
'(-c --check -f --fix)'{-c,--check}"[Check for any problems that may exist]:emaint:((all\:'check all' world\:'check only world file'))" \
'(-c --check -f --fix)'{-f,--fix}"[Fix any problems that may exist]:emaint:((all\:'check all' world\:'check only world file'))"
}
_env-update () {
_arguments -s '(: -)--no-ldconfig[Do not run ldconfig]'
}
_portageq () {
local action
action="$words[2]"
if (( CURRENT == 2 )); then
_values 'command' \
'--help[Show help]' \
'config_protect_mask[Returns the CONFIG_PROTECT_MASK paths]' \
'config_protect[Returns the CONFIG_PROTECT paths]' \
'portdir[Returns PORTDIR paths]' \
'contents[List the files that are installed for a given package]' \
'vdb_path[Returns the path used for the var(installed) package database]' \
'gentoo_mirrors[Returns the mirrors set to use in the portage configuration]' \
'exithandler[MISSING DOCUMENTATION!]' \
'all_best_visible[Returns all best_visible packages (without .ebuild)]' \
'match[Returns a \n separated list of category/package-version]' \
'metadata[Returns metadata values for the specified package]' \
'best_visible[Returns category/package-version (without .ebuild)]' \
'mass_best_visible[Returns category/package-version (without .ebuild)]' \
"has_version[Return code 0 if it's available, 1 otherwise]" \
'envvar[Returns a specific environment variable as exists prior to ebuild.sh]' \
'pkgdir[Returns the PKGDIR path]' \
'best_version[Returns category/package-version (without .ebuild)]' \
'mass_best_version[Returns category/package-version (without .ebuild)]' \
'portdir_overlay[Returns the PORTDIR_OVERLAY path]' \
'distdir[Returns the DISTDIR path]' \
'owners[print the packages that own the files and which files belong to each package]'
elif (( CURRENT == 3 )); then
if [[ "$action" =~ (contents|(all_|mass_|)best_visible|match|metadata|(has|best)_version|owners|mass_best_version) ]]; then
_arguments -s '*:root:_files'
fi
elif (( CURRENT > 3 )); then
if [[ "$action" =~ ((mass_|)best_(visible|version)|has_version) ]]; then
_arguments -s '*:package:_gentoo_packages available'
elif [[ "$action" == owners ]]; then
_arguments -s '*:root:_files'
fi
fi
}
_repoman () {
local previous
previous="$words[CURRENT-1]"
_arguments -s \
'(--force)'--force'[Force commit to proceed, regardless of QA issues]' \
'(-q --quiet -v --verbose)'{-q,--quiet}'[Be less verbose about extraneous info]' \
'(-p --pretend -m --commitmsg -M --commitmsgfile)'{-p,--pretend}'[Dont commit or fix anything; just show what would be done]' \
'(-i --include-masked)'{-i,--include-masked}'[Include masked packages in scans at category or tree level]' \
'(-x --xmlparse)'{-x,--xmlparse}'[Forces the metadata.xml parse check to be carried out]' \
'(-q --quiet -v --verbose)'{-v,--verbose}'[Displays every package name while checking]' \
'(-I --ignore-arches)'{-I,--ignore-arches}'[Ignore arch-specific failures (where arch != host)]' \
'(-m --commitmsg -M --commitmsgfile)'{-m,--commitmsg}'[Adds a commit message via the command line]:message:' \
'(-m --commitmsg -M --commitmsgfile)'{-M,--commitmsgfile}'[Adds a commit message from the specified file]:commit_file:_files' \
'(: -)'{-V,--version}'[Show version info]' \
'(: -)'{-h,--help}'[Show this screen]'
# if we don't have an option that cancel action, or if we don't already have an action.
if ! [[ "$previous" =~ (-h|-V|-m|-M|--version|--help|--commitmsg|--commitmsgfile) ]] &&
! (( $words[(I)(full|last|help|scan|fix|lfull|manifest|commit)] )); then
_values 'action' \
'full[Scan directory tree for QA issues (full listing)]' \
'last[Remember report from last run]' \
'help[Show this screen]' \
'scan[Scan directory tree for QA issues (short listing)]' \
'fix[Fix simple QA issues (stray digests, missing digests)]' \
'lfull[Remember report from last run (full listing)]' \
'manifest[Generate a Manifest (fetches files if necessary)]' \
'commit[Scan directory tree for QA issues; if OK, commit via cvs]'
fi
}
_tbz2tool () {
if (( CURRENT == 2 )); then
_values 'action' 'join' 'split'
elif (( CURRENT > 2 )) && (( CURRENT < 6 )); then
_arguments -s '*:file:_files'
fi
}
zparseopts -D -E -A Args -- -emerge
if (( ${+Args[--emerge]} ));then
_emerge "$@" && return 0
fi
case "$service" in
emerge)
_emerge "$@" && return 0
;;
ebuild)
_ebuild "$@" && return 0
;;
quickpkg)
_quickpkg "$@" && return 0
;;
emaint)
_emaint "$@" && return 0
;;
env-update)
_env-update "$@" && return 0
;;
portageq)
_portageq "$@" && return 0
;;
repoman)
_repoman "$@" && return 0
;;
tbz2tool)
_tbz2tool "$@" && return 0
;;
esac

186
_portage_utils Normal file
View File

@ -0,0 +1,186 @@
#compdef qatom qcheck qdepends qfile qgrep qcache qlist qlop qsearch qsize quse qtbz2 qpkg qxpak
# ------------------------------------------------------------------------------
# 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 Portage Utils (small and faster portage helper tools,
# writen in C, partially — Gentoolkit analog).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Unknown Person
# * Some internet users and some IRC people from #gentoo-* and #zsh on FreeNode
# * Vadim A. Misbakh-Soloviev <mva@mva.name>
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
#<app-portage/portage-utils-0.19>
#
local common_args PORTDIR
var=PORTDIR
[[ -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}`"
common_args=(
{'(--verbose)-v','(-v)--verbose'}'[Make a lot of noise]' \
{'(--quiet)-q','(-q)--quiet'}'[Tighter output; suppress warnings]' \
{'(--nocolor)-C','(-C)--nocolor'}'[Do not output color]' \
{'(--help)-h','(-h)--help'}'[Print this help and exit]' \
{'(--version)-V','(-V)--version'}'[Print version and exit]' \
)
case $service in
qcheck)
_arguments -s $common_args \
{'(--all)-a','(-a)--all'}'[List all packages]' \
{'(--update)-u','(-u)--update'}'[Update chksum and mtimes for packages]' \
'*:packages:_gentoo_packages installed'
;;
qdepends)
_arguments -s $common_args \
{'(--depend)-d','(-d)--depend'}'[Show DEPEND info (default)]' \
{'(--rdepend)-r','(-r)--rdepend'}'[Show RDEPEND info]' \
{'(--pdepend)-p','(-p)--pdepend'}'[Show PDEPEND info]' \
{'(--key)-k','(-k)--key'}'[User defined vdb key]' \
{'(--query)-Q','(-Q)--query'}'[Query reverse deps]' \
{'(--name-only)-N','(-N)--name-only'}'[Only show package name]' \
{'(--all)-a','(-a)--all'}'[Show all DEPEND info]' \
'*:packages:_gentoo_packages installed'
;;
qfile)
_arguments -s $common_args \
{'(--exact)-e','(-e)--exact'}'[Exact match]' \
'*:filename:_files'
;;
qgrep)
_arguments -s $common_args \
{'(--invert-match)-I','(-I)--invert-match'}'[Select non-matching lines]' \
{'(--ignore-case)-i','(-i)--ignore-case'}'[Ignore case distinctions]' \
{'(--with-filename)-H','(-H)--with-filename'}'[Print the filename for each match]' \
{'(--count)-c','(-c)--count'}'[Only print a count of matching lines per FILE]' \
{'(--regexp)-e','(-e)--regexp'}'[Use PATTERN as a regular expression]' \
'*:pattern::'
;;
qcache)
local arches allarches arch
show_archs(){
arches=(${(f)"$(<$PORTDIR/profiles/arch.list)"})
allarches=($archs)
for arch in $arches;do
allarches=($allarches $arch)
done
_describe -t available-arches "arch" allarches
}
_arguments -s $common_args \
'*:arch:show_archs'
;;
qlist)
_arguments -s $common_args \
{'(--installed)-I','(-I)--installed'}'[Just show installed packages]' \
{'(--slots)-S','(-S)--slots'}'[Display installed packages with slots]' \
{'(--umap)-U','(-U)--umap'}'[Display installed packages with flags used]' \
{'(--dups)-D','(-D)--dups'}'[Only show package dups]' \
{'(--exact)-e','(-e)--exact'}'[Exact match (only CAT/PN or PN without PV)]' \
{'(--all)-a','(-a)--all'}'[Show every installed package]' \
{'(--dir)-d','(-d)--dir'}'[Only show directories]' \
{'(--obj)-o','(-o)--obj'}'[Only show objects]' \
{'(--sym)-s','(-s)--sy'}'[Only show symlinks]' \
'*:packages:_gentoo_packages installed'
;;
qlop)
_arguments -s $common_args \
{'(--guage)-g','(-g)--guage'}'[Guage number of times a package has been merged]' \
{'(--time)-t','(-t)--time'}'[Calculate merge time for a specific package]' \
{'(--human)-H','(-H)--human'}'[Print seconds in human readable format (needs -t)]' \
{'(--list)-l','(-l)--list'}'[Show merge history]' \
{'(--unlist)-u','(-u)--unlist'}'[Show unmerge history]' \
{'(--sync)-s','(-s)--sync'}'[Show sync history]' \
{'(--current)-c','(-c)--current'}'[Show current emerging packages]' \
{'(--logfile)-f','(-f)--logfile'}'[Read emerge logfile instead of /var/log/emerge.log]:log:_files' \
'*:packages:_gentoo_packages available'
;;
qsearch)
_arguments -s $common_args \
{'(--all)-a','(-a)--all'}'[List the descriptions of every package in the cache]' \
{'(--cache)-c','(-c)--cache'}'[Use the portage cache]' \
{'(--search)-s','(-s)--search'}'[Regex search package basenames]' \
{'(--desc)-S','(-S)--desc'}'[Regex search package descriptions]' \
{'(--name-only)-N','(-N)--name-only'}'[Only show package name]' \
{'(--homepage)-H','(-H)--homepage'}'[Show homepage info]' \
'*:pattern::'
;;
qsize)
_arguments -s $common_args \
{'(--filesystem)-f','(-f)--filesystem'}'[Show size used on disk]' \
{'(--all)-a','(-a)--all'}'[Size all installed packages]' \
{'(--sum)-s','(-s)--sum'}'[Include a summary]' \
{'(--sum-only)-S','(-S)--sum-only'}'[Show just the summary]' \
{'(--megabyte)-m','(-m)--megabyte'}'[Display size in megabytes]' \
{'(--kilobyte)-k','(-k)--kilobyte'}'[Display size in kilobytes]' \
{'(--byte)-b','(-b)--byte'}'[Display size in bytes]' \
'*:packages:_gentoo_packages installed'
;;
quse)
_arguments -s $common_args \
{'(--exact)-e','(-e)--exact'}'[Show exact non regexp matching using strcmp]' \
{'(--all)-a','(-a)--all'}'[Show annoying things in IUSE]' \
{'(--keywords)-K','(-K)--keywords'}'[Use the KEYWORDS vs IUSE]' \
{'(--license)-L','(-L)--license'}'[Use the LICENSE vs IUSE]' \
{'(--describe)-D','(-D)--describe'}'[Describe the USE flag]' \
{'(--name-only)-N','(-N)--name-only'}'[Only show package name]' \
'*:use flag:_gentoo_packages useflag'
;;
qtbz2)
_arguments -s $common_args \
{'(--join -s --split -t --tarbz2 -x --xpak)-j','(-t --tarbz2 -j -s --split -x --xpak)--join'}'[Join tar.bz2 + xpak into a tbz2]:*:tar.bz2 file and xpak file:_files -g \*.\(tar.bz2\|xpak\)' \
{'(--join -j --split -t --tarbz2 -x --xpak)-s','(-t --tarbz2 -j --join -s -x --xpak)--split'}'[Split a tbz2 into a tar.bz2 + xpak]:tbz2 file:_files -g \*.tbz2' \
{'(--join -j -s --split --tarbz2 -x --xpak)-t','(--join -j -s --split -t -x --xpak)--tarbz2'}'[Just split the tar.bz2]:tbz2 file:_files -g \*.tbz2' \
{'(--join -j -s --split -t --tarbz2 --xpak)-x','(--join -j -s --split -t --tarbz2 -x)--xpak'}'[Just split the xpak]:tbz2 file:_files -g \*.tbz2' \
{'(--stdout)-O','(-O)--stdout'}'[Write files to stdout]'
;;
qpkg)
_arguments -s $common_args \
{'(--pretend)-p','(-p)--pretend'}'[pretend only]' \
{'(--pkgdir)-P','(-P)--pkgdir'}'[alternate package directory]:alternate pkgdir:_files -/' \
'*:Installed packages:_gentoo_packages installed_versions'
;;
qxpak)
_arguments -s $common_args \
{'(--list --extract -x --create -c)-l','(-l --extract -x --create -c)--list'}'[List the contents of an archive]:xpak archive:_files -g \*.xpak' \
{'(--list -l --extract --create -c)-x','(--list -l -x --create -c)--extract'}'[Extract the contents of an archive]:xpak archive:_files -g \*.xpak' \
{'(--list -l --extract -x --create)-c','(--list -l --extract -x -c)--create'}'[Create an archive of a directory/files]:*:archive name and files to archive:_files' \
{'(--dir)-d','(-d)--dir'}'[Change to specified directory]:directory:_files -/' \
{'(--stdout)-O','(-O)--stdout'}'[Write files to stdout]'
;;
esac