109 lines
2.7 KiB
Plaintext
Raw Normal View History

# This function is required by _dpkg() and _dpkg-reconfigure()
_have grep-status && {
_comp_dpkg_installed_packages()
{
2009-10-04 19:42:50 +02:00
grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package
}
} || {
_comp_dpkg_installed_packages()
{
command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
2009-10-04 19:42:50 +02:00
half-configured|config-files" \
-Ee "^Essential: yes" | \
command grep "Package: $1" | cut -d\ -f2
}
}
# Debian dpkg(8) completion
#
_dpkg()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
_expand || return 0
local i=$cword
2009-10-04 19:42:50 +02:00
# find the last option flag
if [[ $cur != -* ]]; then
while [[ $prev != -* && $i -ne 1 ]]; do
2009-10-04 19:42:50 +02:00
i=$((i-1))
prev=${words[i-1]}
2009-10-04 19:42:50 +02:00
done
fi
case $prev in
-c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \
--contents|--info|--fsys-tarfile|--field|--control|--extract| \
--show)
2009-10-04 19:42:50 +02:00
_filedir '?(u)deb'
return 0
;;
-b|--build)
2009-10-04 19:42:50 +02:00
_filedir -d
return 0
;;
-s|-p|-l|--status|--print-avail|--list)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) )
return 0
;;
-S|--search)
2009-10-04 19:42:50 +02:00
_filedir
return 0
;;
-r|-L|-P|--remove|--purge|--listfiles)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
return 0
;;
esac
$split && return
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2011-04-04 22:14:39 +03:00
} &&
complete -F _dpkg dpkg dpkg-deb
# Debian GNU dpkg-reconfigure(8) completion
#
_dpkg_reconfigure()
{
local cur prev words cword
_init_completion || return
local opt
case $prev in
-f|--frontend)
2009-12-21 00:09:02 +02:00
opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) )
2009-10-04 19:42:50 +02:00
opt=( ${opt[@]##*/} )
opt=( ${opt[@]%.pm} )
COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) )
return 0
;;
-p|--priority)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) )
return 0
;;
esac
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only \
--help --showold --force --terse' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
else
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
fi
} &&
complete -F _dpkg_reconfigure -o default dpkg-reconfigure
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh