|
|
elif (( CURRENT > 2 ));then | elif (( CURRENT > 2 ));then |
case "$words[2]" in | case "$words[2]" in |
unmerge|-C) | unmerge|-C) |
_arguments -s \ |
if compset -P '(\\|)[><][=]'; then |
'*:installed pkgname with versions:_portage_unmerge' "$common_args[@]" && return 0 |
_arguments -s \ |
|
'*:installed pkgname with versions:_portage_unmerge_vers' "$common_args[@]" && return 0 |
|
elif compset -P '(\\|)[<=>]'; then |
|
_arguments -s \ |
|
'*:installed pkgname with versions:_portage_unmerge_vers' "$common_args[@]" && return 0 |
|
else |
|
_arguments -s \ |
|
'*:installed pkgname:_portage_unmerge' "$common_args[@]" && return 0 |
|
fi |
;; | ;; |
clean|-c) | clean|-c) |
_arguments -s \ | _arguments -s \ |
|
|
_arguments -s \ | _arguments -s \ |
'*:use package only:_portage_tbz2list' "$common_args[@]" && return 0 | '*:use package only:_portage_tbz2list' "$common_args[@]" && return 0 |
;; | ;; |
depclean|help|-h|info|regen|sync|rsync|--searchdesc|-S|search|-s|inject|-j|prune|-P) |
depclean|help|-h|info|regen|sync|rsync|--searchdesc|-S|search|-s|prune|-P) |
|
;; |
|
--resume|--skipfirst) |
|
_arguments -s \ |
|
'--skipfirst[Removes the first package in the resume list]' \ |
|
"$common_args[@]" && return 0 |
;; | ;; |
*) | *) |
_arguments -s \ | _arguments -s \ |
|
|
state='' | state='' |
case "$lstate" in | case "$lstate" in |
actions) | actions) |
|
if compset -P '(\\|)[><][=]'; then |
_alternative \ | _alternative \ |
':emerge actions:_actions' \ |
'*:portage:_ebuild_cache' |
'*:portage:_portage_pkglist' |
|
|
elif compset -P '(\\|)[<=>]'; then |
|
_alternative \ |
|
'*:portage:_ebuild_cache' |
|
|
|
else |
|
_alternative \ |
|
':emerge actions:_actions' \ |
|
'*:portage:_portage_pkglist' |
|
fi |
|
|
;; | ;; |
install_portage) | install_portage) |
|
if compset -P '(\\|)[><][=]'; then |
_alternative \ | _alternative \ |
'*:portage:_portage_pkglist' |
'*:portage:_ebuild_cache' |
|
elif compset -P '(\\|)[<=>]'; then |
|
_alternative \ |
|
'*:portage:_ebuild_cache' |
|
else |
|
_alternative \ |
|
'*:portage:_portage_pkglist' |
|
fi |
;; | ;; |
esac | esac |
done | done |
} | } |
| |
#Function to show only installed packages "cat/name-ver" |
#Function to show only installed packages -- pkgname (no category or version #) |
_portage_unmerge(){ | _portage_unmerge(){ |
installed_portage=(/var/db/pkg/*-*/*) | installed_portage=(/var/db/pkg/*-*/*) |
installed_dir=/var/db/pkg/ |
installed_pkgname=${(M)${${installed_portage##*/}%%-[0-9]*}} |
installed_pkg=${installed_portage//$installed_dir/} |
_tags -s installed_pkgname && { compadd "$@" ${(kv)=installed_pkgname} } |
_tags -s installed_pkg && { compadd "$@" -k installed_pkg || compadd "$@" ${(kv)=installed_pkg} } |
_path_files -/ -W "/var/db/pkg/" |
|
} |
|
|
|
#Function to show only installed packages -- cat/name-ver |
|
_portage_unmerge_vers(){ |
|
installed_portage=(/var/db/pkg/*-*/*) |
|
installed_pkgname=${(M)${${installed_portage##*/}}} |
|
_tags -s installed_pkgname && { compadd "$@" ${(kv)=installed_pkgname} } |
|
_path_files -/ -W "/var/db/pkg/" |
} | } |
| |
#Functions to show "cat/name", classes and dependencies | #Functions to show "cat/name", classes and dependencies |
|
|
#[[ -n "${portdir_overlay}" ]] && _path_files -/ -W "${portdir_overlay}" | #[[ -n "${portdir_overlay}" ]] && _path_files -/ -W "${portdir_overlay}" |
_path_files -g \*.ebuild | _path_files -g \*.ebuild |
} | } |
|
#Function for matching all ebuilds pkg-ver (slow if asking for all packages) |
|
_ebuild_cache(){ |
|
if _cache_invalid portage_ebuilds || ! _retrieve_cache portage_ebuilds; then |
|
|
|
overlay_ebuilds=($portdir_overlay/*-*/*/*) |
|
overlay_list=${${(M)${overlay_ebuilds##*/}#*ebuild}%%.ebuild} |
|
metadata_ebuilds=($portdir/metadata/cache/*-*/*) |
|
metadata_list=${(M)${${metadata_ebuilds##*/}}} |
|
|
|
_store_cache portage_ebuilds metadata_list overlay_list |
|
fi |
|
_tags -s metadata_list && {compadd "$@" ${(kv)=metadata_list} } |
|
_tags -s overlay_list && {compadd "$@" ${(kv)=overlay_list} } |
|
} |
|
|
|
local update_policy |
|
zstyle -s ":completion:*:*:emerge:*" cache-policy update_policy |
|
if [[ -z "$update_policy" ]]; then |
|
zstyle ":completion:*:*:emerge:*" cache-policy _ebuilds_caching_policy |
|
fi |
|
|
|
_ebuilds_caching_policy () { |
|
# rebuild if cache is more than a week old |
|
oldp=( "$1"(mw+1) ) |
|
(( $#oldp )) && return 0 |
|
} |
| |
common_args=( | common_args=( |
{'(-p)--pretend','(--pretend)-p'}'[simply display what would be done]' |
{'(-p -a --ask)--pretend','(--pretend -a --ask)-p'}'[simply display what would be done]' |
|
{'(-p -a --pretend)--ask','(--pretend -p --ask)-a'}'[ask what would be done]' |
{'(-d)--debug','(--debug)-d'}'[Tells emerge to run the emerge command in debug mode]' | {'(-d)--debug','(--debug)-d'}'[Tells emerge to run the emerge command in debug mode]' |
) | ) |
install_args=( | install_args=( |
|
|
{'(--usepkg --changelog -l)-k','(-k --changelog -l)--usepkg'}'[Tells emerge to use binary packages if available]' | {'(--usepkg --changelog -l)-k','(-k --changelog -l)--usepkg'}'[Tells emerge to use binary packages if available]' |
{'(--usepkgonly --changelog -l)-K','(-K --changelog -l)--usepkgonly'}'[Tells emerge to use binary packages only]' | {'(--usepkgonly --changelog -l)-K','(-K --changelog -l)--usepkgonly'}'[Tells emerge to use binary packages only]' |
{'(--verbose)-v','(-v)--verbose'}'[Tell emerge to run in verbose mode]' | {'(--verbose)-v','(-v)--verbose'}'[Tell emerge to run in verbose mode]' |
'(-p --pretend)--columns[Displays versions in aligned format]' |
'(-p --pretend -a --ask)--columns[Displays versions in aligned format]' |
'--resume[Resumes the last merge operation]' | '--resume[Resumes the last merge operation]' |
'--skipfirst[Removes the first package in the resume list]' |
|
) | ) |
| |
_options() { |
|
_arguments -s \ |
|
"$unmerge_args[@]" "$common_args[@]" "$install_args[@]" |
|
} |
|
|
|
_actions() { | _actions() { |
_values "emerge actions" \ | _values "emerge actions" \ |
'sync[Initiates a portage tree update]' \ | 'sync[Initiates a portage tree update]' \ |