77 lines
2.6 KiB
Plaintext
Raw Normal View History

# Debian apt-get(8) completion -*- shell-script -*-
_apt_get()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
local special i
for (( i=0; i < ${#words[@]}-1; i++ )); do
if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download) ]]; then
special=${words[i]}
2009-10-04 19:42:50 +02:00
fi
done
2011-11-09 23:28:11 +02:00
if [[ -n $special ]]; then
2009-10-04 19:42:50 +02:00
case $special in
remove|autoremove|purge)
2011-11-09 23:28:11 +02:00
if [[ -f /etc/debian_version ]]; then
2009-10-04 19:42:50 +02:00
# Debian system
COMPREPLY=( $( \
_xfunc dpkg _comp_dpkg_installed_packages $cur ) )
2009-10-04 19:42:50 +02:00
else
# assume RPM based
_xfunc rpm _rpm_installed_packages
2009-10-04 19:42:50 +02:00
fi
return 0
;;
source)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
2> /dev/null ) $( apt-cache dumpavail | \
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
return 0
;;
2009-10-04 19:42:50 +02:00
*)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
2> /dev/null ) )
return 0
;;
esac
fi
case $prev in
-c|--config-file)
2009-10-04 19:42:50 +02:00
_filedir
return 0
;;
-t|--target-release|--default-release)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( apt-cache policy | \
command grep "release.o=Debian,a=$cur" | \
2009-10-04 19:42:50 +02:00
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y -u -t -b -c -o \
--download-only --fix-broken --help --version --ignore-missing \
--fix-missing --no-download --quiet --simulate --just-print \
--dry-run --recon --no-act --yes --assume-yes --show-upgraded \
--only-source --compile --build --ignore-hold --target-release \
--no-upgrade --force-yes --print-uris --purge --reinstall \
--list-cleanup --default-release --trivial-only --no-remove \
--diff-only --no-install-recommends --tar-only --config-file \
--option --auto-remove' -- "$cur" ) )
else
COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
dist-upgrade install remove purge source build-dep \
download \
2009-10-04 19:42:50 +02:00
check clean autoclean autoremove' -- "$cur" ) )
fi
return 0
} &&
complete -F _apt_get apt-get
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh