Split yum and yum-arch completion into contrib/yum.

This commit is contained in:
Ville Skyttä 2009-03-30 21:48:09 +03:00
parent dc88329e8e
commit aa2851d549
3 changed files with 121 additions and 116 deletions

View File

@ -6564,122 +6564,6 @@ _mc()
} &&
complete -F _mc $filenames mc
# 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
case $cur in
--*)
COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
return 0
;;
-*)
COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
return 0
;;
esac
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 list \
search info provides clean groupinstall groupupdate \
grouplist deplist erase groupinfo groupremove \
localinstall localupdate makecache resolvedep \
shell whatprovides' -- $cur ) )
;;
esac
}
complete -F _yum $filenames yum
# yum-arch(8) completion
#
_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
}
# ImageMagick completion
#
have convert && {

118
contrib/yum Normal file
View File

@ -0,0 +1,118 @@
# -*- 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
case $cur in
--*)
COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
return 0
;;
-*)
COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
return 0
;;
esac
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 list \
search info provides clean groupinstall groupupdate \
grouplist deplist erase groupinfo groupremove \
localinstall localupdate makecache resolvedep \
shell whatprovides' -- $cur ) )
;;
esac
}
complete -F _yum $filenames yum
# yum-arch(8) completion
#
_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
}

3
debian/changelog vendored
View File

@ -3,6 +3,9 @@ bash-completion (1:1.x) UNRELEASED; urgency=low
[ David Paleino ]
* Prepare for future development.
[ Ville Skyttä ]
* Split yum and yum-arch completion into contrib/yum.
-- David Paleino <d.paleino@gmail.com> Wed, 25 Mar 2009 23:18:24 +0100
bash-completion (1:1.0-1) UNRELEASED; urgency=low