119 lines
2.6 KiB
Plaintext
Raw Normal View History

# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum(8) completion
#
have yum && {
_yum_list()
{
if [[ "$1" == all ]] ; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
grep -iv '^\(Available\|Installed\|Updated\) Packages' | \
sed -e 's/[[:space:]].*//' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
_yum()
{
local cur prev special
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
special=${COMP_WORDS[i]}
fi
done
if [ -n "$special" ]; then
case $special in
install)
_yum_list available
return 0
;;
deplist|info)
_yum_list all
return 0
;;
upgrade|update)
_yum_list updates
return 0
;;
remove|erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help -t --tolerant -C -c -R \
-d --showduplicates -e -q --quiet -v --verbose -y \
--version --installroot --enablerepo --disablerepo -x \
--exclude --disableexcludes --obsoletes --noplugins \
--nogpgcheck --disableplugin --enableplugin \
--skip-broken --color' -- $cur ) )
return 0
fi
case $prev in
list)
COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
;;
clean)
COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
;;
localinstall|localupdate)
# TODO: should not match *src.rpm
_filedir rpm
;;
-c)
_filedir
;;
--installroot)
_filedir -d
;;
*)
COMPREPLY=( $( compgen -W 'install update check-update \
upgrade remove erase list info provides whatprovides \
clean makecache groupinstall groupupdate grouplist \
groupremove groupinfo search shell resolvedep \
localinstall localupdate deplist repolist help' \
-- $cur ) )
;;
esac
}
} &&
complete -F _yum $filenames yum
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch