#compdef gensync equery qpkg #Function to show gensync overlays located in /etc/gensync _overlays(){ overlay=$(grep -h id= /etc/gensync/* | sed -e 's/id="\(.*\)"$/\1/') _tags overlay && { compadd "$@" ${(kv)=overlay} } } #show portage categories without / at end; app-cdr instead of app-cdr/ -- this can probably be done with _files, but I'm lazy _category(){ categories=($portdir/metadata/cache/*-*) category=${(M)${${categories##*/}}} _tags -s category && { compadd "$@" ${(kv)=category} } } #Function to show only installed packages -- pkgname (no category or version #) _portage_installed(){ installed_portage=(/var/db/pkg/*-*/*) installed_pkgname=${(M)${${installed_portage##*/}%%-[0-9]*}} _tags -s installed_pkgname && { compadd "$@" ${(kv)=installed_pkgname} } } #moved out of equery _equery_val(){ _values "equery actions" \ 'files[list files owned by pkg]' \ 'list[list all packages matching pattern]' \ 'belongs[list all packages owning file]' \ 'uses[display USE flags for package]' \ 'which[print full path to ebuild for package]' \ 'depgraph[display a dependency tree for package]' \ 'check[check files against recorded md5sums and timestamps]' \ 'size[print size of files contained in package]' } #Function to show all available portage names _portage_pkglist(){ portage_pkglist="$portage_pkglist" _tags -s portage_pkglist && { compadd "$@" ${(kv)=portage_pkglist} } _path_files -/ -F "*CVSROOT" -F "*eclass" -F "*distfiles" -F "*licences" -W "${portdir}" } #Reading informations from make.conf [[ -n "${PORTDIR}" ]] && portdir="${PORTDIR}" [[ -n "${PKGDIR}" ]] && pkgdir="${PKGDIR}" if [[ -n "${PORTDIR_OVERLAY}" ]] ; then for overlay in ${=PORTDIR_OVERLAY} ; do portdir_overlay=(${overlay} ${portdir_overlay}) done fi [[ -r /etc/make.globals ]] && source /etc/make.globals [[ -r /etc/make.conf ]] && source /etc/make.conf [[ -z "${portdir}" ]] && portdir="${PORTDIR}" [[ -z "${pkgdir}" ]] && pkgdir="${PKGDIR}" if [[ -z "${portdir_overlay}" ]] ; then for overlay in ${=PORTDIR_OVERLAY} ; do portdir_overlay=(${overlay} ${portdir_overlay}) done fi portage_pkglist=(${portdir}/*-*/* ${portdir_overlay}/*-*/*) portage_pkglist=(${portage_pkglist##*/}) case $service in gensync) _arguments \ '(- :)'{--list-sources,-l}'[list known rsync sources]' \ '()'{--no-color,-C}'[turn off colours]:overlays:_overlays' \ '(- :)'{--help,-h}'[show help]' \ '(- :)'{--version,-V}'[display version info]' \ '(- :)'':overlays:_overlays' ;; qpkg) excl=( --help -h --query-deps -q ) check=( --check-md5 -cm --check-time -ct --check -c ) arg=( --info -i --list -l --non-masked -n --masked -m --installed -I --uninstalled -U --group -g ) find=( --find-file -f --find-pattern -fp ) dups=( --dups -d --slot -s) _arguments \ "($check $excl $find $dups 1)"{--find-file,-f}"[finds package that owns file]:file:_files" \ "($check $excl $find $dups 1)"{--find-pattern,-fp}"[finds package that owns file matching pattern]:pattern:" \ "($excl $check $arg $find --dups -d )"{--dups,-d}"[print packages that have multiple versions installed]" \ "($excl $check $arg $find --slot -s 1)"{--slot,-s}"[only print duplicates of the same slot]" \ "($check $excl --installed -I --uninstalled -U $dups -d)"{--uninstalled,-U}"[include only uninstalled packages]" \ "($excl --uninstalled -U --installed -I $dups -d)"{--installed,-I}"[include only installed packages]" \ "($excl --group -g $dups -d)"{--group,-g}"[find by group]:group:_category" \ "($check $excl --list -l $dups -d)"{--list,-l}"[list package contents]" \ "($excl --info -i $dups -d 1)"{--info,-i}"[get package description and home page]:package:_portage_pkglist" \ "($excl $check $find $dups --uninstalled -U)"{--check-time,-ct}"[verify package file timestamps]" \ "($excl $check $find $dups --uninstalled -U)"{--check-md5,-cm}"[verify package files md5]" \ "($excl $check $find $dups --uninstalled -U)"{--check,-c}"[verify mtimes and md5]" \ "($excl $find --query-deps -q $dups -d 1)"{--query-deps,-q}"[display all installed packages depending on selected packages]:package:_portage_pkglist" \ "()"{--no-color,-nc}"[dont use colors]" \ "*--verbose[be more verbose (2 levels)]" \ "*-v[be more verbose (2 levels)]" \ "($excl --non-masked -n --masked -m $dups)"{--masked,-m}"[include only masked packages]" \ "($excl --non-masked -n --masked -m $dups)"{--non-masked,-n}"[include only non-masked packages]" \ "(- :)"{--help,-h}"[show help]" \ "(--info -i --query-deps -q --slot -s)1:package:_portage_installed" ;; equery) local prev="$words[CURRENT-1]" prev2="$words[CURRENT-2]" if (( CURRENT == 2 ));then _equery_val _arguments \ $common_args && return 0 elif (( CURRENT > 2 ));then case "$prev" in files|--timestamp|--md5sum|--type) _arguments -s \ '--timestamp[append timestamp]' \ '--md5sum[append md5sum]' \ '--type[prepend file type]' \ '*:installed pkgname:_portage_installed' && return 0 ;; belongs|--earlyout) _arguments -s \ '(-c --category)'{-c,--category}'[only search in specified category]' \ '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ '*:file:_files' && return 0 ;; --category|-c) _arguments -s \ '*:category:_category' && return 0 ;; list|--installed|-i|--exclude-installed|-I|-p|--portage-tree|-o|--overlay-tree) _arguments -s \ '(-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]' \ '*:package:_portage_installed' && return 0 ;; uses|which) _arguments \ '*:package:_portage_pkglist' \ && return 0 ;; depgraph|-U|--no-useflags|-l|--linear) _arguments -s \ '(-U --no-useflags)'{-U,--no-useflags}'[do not show USE flags]' \ '(-l --linear)'{-l,--linear}'[do not use fancy formatting]' \ '*:package:_portage_installed' \ && return 0 ;; size|-b|--bytes) _arguments -s \ '(-b --bytes)'{-b,--bytes}'[report size in bytes]' \ '*:package:_portage_installed' \ && return 0 ;; check) _arguments -s \ '*:package:_portage_installed' \ && return 0 ;; --nocolor|-C|--quiet|-q) _equery_val _arguments \ $common_args && return 0 ;; esac [[ $prev2 == (--category|-c) ]] && _arguments '(-c --category)'{-c,--category}'[only search in specified category]' \ '(-e --earlyout)'{-e,--earlyout}'[stop when first match found]' \ '*:file:_files' && return 0 fi common_args=( {'(--nocolor)-C','(-C)--nocolor'}'[turns off colors]' {'(--quiet)-q','(-q)--quiet'}'[minimal output]' {'(--help)-h','(-h)--help'}'[show help]' ) ;; esac