#compdef genlop # ZSH completion function for genlop # # Original authors of portage completion # Author: baptux # Author: Mamoru KOMACHI # # Adapted for genlop by oberyno _genlop () { local state if (( CURRENT == 2 ));then _arguments -s \ '*:*:->ebuilds' \ "$common_args[@]" "$general_args[@]" "$single_args[@]" && return 0 elif (( CURRENT > 2 ));then case "$words[2]" in --unmerge|-u) _arguments -s \ '*:*:->install_portage' \ "$common_args[@]" "$general_args[@]" && return 0 ;; --current|-c) _arguments -s \ '*:only works when an emerge is in progress:' \ "$common_args[@]" && return 0 ;; --pretend|-p) _arguments -s \ '*:needs a piped emerge; otherwise will do nothing:' \ "$common_args[@]" && return 0 ;; --rsync|-r|--list|-l) _arguments -s \ "$common_args[@]" "$general_args[@]" && return 0 ;; --version|-v|--help|-h) _arguments -s \ "$common_args[@]" && return 0 ;; *) _arguments -s \ '*:*:->ebuilds' \ "$common_args[@]" "$general_args[@]" && return 0 ;; esac fi while [[ -n "$state" ]]; do lstate=$state state='' case "$lstate" in ebuilds) _alternative \ '*:installed packages:_portage_installed' ;; install_portage) _alternative \ '*:installed packages:_portage_pkglist' ;; esac done } _portage_installed(){ installed_pkg=$(_call_program codesets ls /var/db/pkg/* | grep -v /var/db/pkg | sed -e 's/{-r,_pre}[0-99]//' -e 's/-[0-99].*//' -e '/^$/d' | sort ) _tags installed_pkg && { compadd "$@" -k installed_pkg || compadd "$@" ${(kv)=installed_pkg} } _path_files -/ -W /var/db/pkg/ } #Function to show all available portage names _portage_pkglist(){ portage_pkglist="$portage_pkglist" _tags -s portage_pkglist && { compadd "$@" -k portage_pkglist || compadd "$@" ${(kv)=portage_pkglist} } _path_files -/ -F "*CVSROOT" -F "*eclass" -F "*distfiles" -F "*licences" -F "*files" -W "${portdir}" _path_files -g \*.ebuild } common_args=( {'(-n)--nocolor','(--nocolor)-n'}'[disable colored output]' ) general_args=( {'(--time)-t','(-t)--time'}'[calculate merge time]' {'(--gmt)-g','(-g)--gmt'}'[display time in GMT/UTC format (default is local time)]' {'(--info)-i','(-i)--info'}'[prints brief summary about installed ebuild]' {'(--file)-f','(-f)--file'}'[specify the logfile to use]:filename:_files' {'(--rsync -r --unmerge)-u','(--rsync -r -u)--unmerge'}'[show when packages have been unmerged]' '*--date[specify date of event]:enter:_guard "^--*" enter date' {'(--search -s --info -i --time -t --unmerge -u --rsync)-r','(--search -s --info -i --time -t --unmerge -u -r)--rsync'}'[looks for portage rsync/sync history]' {'(--search -s --info -i --list)-l','(--search -s --info -i -l)--list'}'[list complete merge history]' {'(--rsync -r --search)-s','(--rsync -r -s)--search'}'[select ebuilds matching the provided regular expression]:enter:_guard "^--*" search pattern' ) single_args=( {'(--current)-c','(-c)--current'}'[show the current merge in action]' {'(--pretend)-p','(-p)--pretend'}'[take output from a piped emerge -p and calculate estimated build time]' {'(--version)-v','(-v)--version'}'[output version information]' {'(--help)-h','(-h)--help'}'[show help]' ) _options() { _arguments -s \ "$common_args[@]" "$general_args[@]" "$single_args[@]" } #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##*/})