rpm completion updated for extra options in rpm 4.x (added --eval, --pipe,
--rcfile, etc.) some minor bug fixes to rpm completion; code tidied in places added some outstanding long options to rpm completion (--install, --freshen, --upgrade, --info, --list, --state, --docfiles, --queryformat, --verify etc.) added -g group completion
This commit is contained in:
parent
b1513938c3
commit
ab80ab8acb
129
bash_completion
129
bash_completion
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# <![CDATA[
|
# <![CDATA[
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.9 2000/10/29 23:17:19 ianmacd Exp $
|
# $Id: bash_completion,v 1.10 2000/11/20 21:41:43 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -527,8 +527,7 @@ _cvs()
|
|||||||
}
|
}
|
||||||
complete -F _cvs cvs
|
complete -F _cvs cvs
|
||||||
|
|
||||||
# rpm(8) completion. This isn't exhaustive yet, but still provides
|
# rpm(8) completion. This is quite comprehensive now and covers rpm 4.x
|
||||||
# quite a lot of functionality.
|
|
||||||
#
|
#
|
||||||
_rpm()
|
_rpm()
|
||||||
{
|
{
|
||||||
@ -545,6 +544,12 @@ _rpm()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_package_list()
|
||||||
|
{
|
||||||
|
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
|
||||||
|
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$/\1/p' ) )
|
||||||
|
}
|
||||||
|
|
||||||
local cur cur_nodash prev
|
local cur cur_nodash prev
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
@ -570,7 +575,9 @@ _rpm()
|
|||||||
--*)
|
--*)
|
||||||
COMPREPLY=( $( compgen -W 'help version initdb \
|
COMPREPLY=( $( compgen -W 'help version initdb \
|
||||||
checksig recompile rebuild resign addsign rebuilddb \
|
checksig recompile rebuild resign addsign rebuilddb \
|
||||||
showrc setperms setgids' ${cur_nodash#-} ) )
|
showrc setperms setgids tarbuild eval install \
|
||||||
|
upgrade query freshen erase verify querytags' \
|
||||||
|
${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@ -588,16 +595,31 @@ _rpm()
|
|||||||
COMPREPLY=( $( compgen -d $cur ) )
|
COMPREPLY=( $( compgen -d $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
--eval)
|
||||||
|
# get a list of macros (char class contains a space and tab)
|
||||||
|
COMPREPLY=( $( sed -ne 's/^\(%'${cur#\%}'[^ ]*\).*$/\1/p' \
|
||||||
|
/usr/lib/rpm/macros ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--pipe)
|
||||||
|
COMPREPLY=( $( compgen -c $cur ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--rcfile)
|
||||||
|
COMPREPLY=( $( compgen -f $cur ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "${COMP_WORDS[1]}" in
|
case "${COMP_WORDS[1]}" in
|
||||||
-[iFU]*)
|
-@([iFU]*|-install|-freshen|-upgrade))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
|
COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
|
||||||
replacefiles root excludedocs includedocs noscripts rcfile \
|
replacefiles root excludedocs includedocs noscripts rcfile \
|
||||||
ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
|
ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
|
||||||
ftpport justdb httpproxy httpport noorder relocate badreloc \
|
ftpport justdb httpproxy httpport noorder relocate badreloc \
|
||||||
notriggers excludepath ignoresize oldpackage' ${cur_nodash#-} ))
|
notriggers excludepath ignoresize oldpackage define eval \
|
||||||
|
pipe queryformat' ${cur_nodash#-} ))
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
@ -609,8 +631,9 @@ _rpm()
|
|||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
||||||
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
||||||
httpport provides triggers dump changelog dbpath filesbypkg' \
|
httpport provides triggers dump changelog dbpath filesbypkg \
|
||||||
${cur_nodash#-} ) )
|
define eval pipe showrc info list state docfiles \
|
||||||
|
configfiles queryformat' ${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
@ -623,25 +646,26 @@ _rpm()
|
|||||||
COMPREPLY=( $( compgen -f $cur ) )
|
COMPREPLY=( $( compgen -f $cur ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-e)
|
-*g)
|
||||||
|
# package group completion
|
||||||
|
local IFS=$(echo -e "\t")
|
||||||
|
# remove trailing backslash, or grep will complain
|
||||||
|
cur=${cur%'\'}
|
||||||
|
COMPREPLY=( $( rpm -qa --queryformat '%{group}\n' | \
|
||||||
|
grep ^$cur ) )
|
||||||
|
# backslash escape spaces and translate newlines to tabs
|
||||||
|
COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | \
|
||||||
|
tr '\n' '\t' ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-@(e|-erase))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
|
COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
|
||||||
nodeps test' ${cur_nodash#-} ) )
|
nodeps test' ${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# complete on basename of installed RPMs
|
add_package_list
|
||||||
COMPREPLY=( $( rpm -qa | \
|
|
||||||
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$/\1/p' ) )
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
-qa*)
|
|
||||||
# complete on list of relevant options
|
|
||||||
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
|
||||||
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
|
||||||
httpport provides triggers dump changelog dbpath specfile \
|
|
||||||
querybynumber last filesbypkg' ${cur_nodash#-} ) )
|
|
||||||
dashify
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-q*)
|
-q*)
|
||||||
@ -649,49 +673,53 @@ _rpm()
|
|||||||
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
|
||||||
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
|
||||||
httpport provides triggers dump changelog dbpath specfile \
|
httpport provides triggers dump changelog dbpath specfile \
|
||||||
querybynumber last filesbypkg' ${cur_nodash#-} ) )
|
querybynumber last filesbypkg define eval pipe showrc info \
|
||||||
|
list state docfiles configfiles queryformat' \
|
||||||
|
${cur_nodash#-} ) )
|
||||||
|
dashify
|
||||||
|
# return if $cur is an option
|
||||||
|
[[ "$cur" == -* ]] && return 0
|
||||||
|
# don't complete on packages if we are querying all packages
|
||||||
|
[[ ${COMP_WORDS[1]} == -qa* ]] && return 0
|
||||||
|
add_package_list
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-@(K|-checksig))
|
||||||
|
# complete on list of relevant options
|
||||||
|
COMPREPLY=( $( compgen -W 'nopgp nogpg nomd5' \
|
||||||
|
${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# add a list of RPMS to possible completions
|
# add a list of RPMS to possible completions
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
|
COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
|
||||||
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$/\1/p' ) )
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-[Vy]*)
|
-@([Vy]*|-verify))
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
|
COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
|
||||||
noscripts nomd5 nopgp' ${cur_nodash#-} ) )
|
noscripts nomd5' ${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# add a list of RPMS to possible completions
|
# add a list of RPMS to possible completions
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
|
|
||||||
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$/\1/p' ) )
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-b*)
|
-[bt]*)
|
||||||
# complete on list of relevant options
|
# complete on list of relevant options
|
||||||
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
|
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
|
||||||
rmsource test sign buildroot target buildarch buildos' \
|
rmsource test sign buildroot target buildarch buildos \
|
||||||
${cur_nodash#-} ) )
|
nobuild' ${cur_nodash#-} ) )
|
||||||
dashify
|
dashify
|
||||||
# return if $cur is an option
|
# return if $cur is an option
|
||||||
[[ "$cur" == -* ]] && return 0
|
[[ "$cur" == -* ]] && return 0
|
||||||
# complete on .spec files
|
if [[ ${COMP_WORDS[1]} == -b* ]]; then
|
||||||
COMPREPLY=( $( compgen -G $cur\*.spec ) )
|
# complete on .spec files
|
||||||
return 0
|
COMPREPLY=( $( compgen -G $cur\*.spec ) )
|
||||||
;;
|
else
|
||||||
-t*)
|
# complete on .tar files
|
||||||
# complete on list of relevant options
|
COMPREPLY=( $( compgen -G $cur\*.+(tgz|tar.+(gz|bz2)) ) )
|
||||||
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
|
fi
|
||||||
rmsource test sign buildroot target buildarch buildos' \
|
|
||||||
${cur_nodash#-} ) )
|
|
||||||
dashify
|
|
||||||
# return if $cur is an option
|
|
||||||
[[ "$cur" == -* ]] && return 0
|
|
||||||
# complete on .tar.gz files
|
|
||||||
COMPREPLY=( $( compgen -G $cur\*.tar.gz ) )
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--re@(build|compile))
|
--re@(build|compile))
|
||||||
@ -699,15 +727,18 @@ _rpm()
|
|||||||
COMPREPLY=( $( compgen -G $cur\*.src.rpm ) )
|
COMPREPLY=( $( compgen -G $cur\*.src.rpm ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--@(checksig|@(re|add)sign))
|
--tarbuild)
|
||||||
|
# complete on tarred sources
|
||||||
|
COMPREPLY=( $( compgen -G $cur\*.+(tgz|tar.+(gz|bz2)) ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--@(re|add)sign)
|
||||||
# complete on RPMs
|
# complete on RPMs
|
||||||
COMPREPLY=( $( compgen -G $cur\*.rpm ) )
|
COMPREPLY=( $( compgen -G $cur\*.rpm ) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--set@(perms|gids))
|
--set@(perms|gids))
|
||||||
# complete on installed RPMs
|
add_package_list
|
||||||
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
|
|
||||||
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.]\+$/\1/p' ) )
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
x
Reference in New Issue
Block a user