2009-03-30 21:48:09 +03:00
|
|
|
# -*- 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
|
|
|
|
|
2009-03-30 22:04:42 +03:00
|
|
|
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 ) )
|
2009-03-30 21:48:09 +03:00
|
|
|
return 0
|
2009-03-30 22:04:42 +03:00
|
|
|
fi
|
2009-03-30 21:48:09 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
*)
|
2009-03-30 22:04:42 +03:00
|
|
|
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 ) )
|
2009-03-30 21:48:09 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2009-03-30 21:54:30 +03:00
|
|
|
} &&
|
2009-03-30 21:48:09 +03:00
|
|
|
complete -F _yum $filenames yum
|
|
|
|
|
|
|
|
# yum-arch(8) completion
|
|
|
|
#
|
2009-03-30 21:54:30 +03:00
|
|
|
have yum-arch &&
|
2009-03-30 21:48:09 +03:00
|
|
|
_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
|
2009-03-30 21:54:30 +03:00
|
|
|
} &&
|
2009-03-30 21:48:09 +03:00
|
|
|
complete -F _yum_arch $filenames yum-arch
|