1 # Debian apt(8) completion -*- shell-script -*-
5 local sourcesdir="/etc/apt/sources.list.d"
6 local cur prev words cword
7 _init_completion || return
9 # see if the user selected a command already
14 "install" "remove" "purge" "autoremove"
16 "upgrade" "full-upgrade" "dist-upgrade"
21 for (( i=0; i < ${#words[@]}-1; i++ )); do
22 if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
28 # supported options per command
29 if [[ "$cur" == -* ]]; then
31 install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
32 COMPREPLY=( $( compgen -W '--show-progress
33 --fix-broken --purge --verbose-versions --auto-remove
41 --reinstall --solver' -- "$cur" ) )
45 COMPREPLY=( $( compgen -W '--list-cleanup
50 COMPREPLY=( $( compgen -W '--installed --upgradable
58 COMPREPLY=( $( compgen -W '-a --all-versions
65 # specific command arguments
66 if [[ -n $command ]]; then
68 remove|purge|autoremove)
69 if [[ -f /etc/debian_version ]]; then
72 _xfunc dpkg _comp_dpkg_installed_packages $cur ) )
75 _xfunc rpm _rpm_installed_packages
80 COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
85 COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
91 COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \
98 # no command yet, show what commands we have
99 if [ "$command" = "" ]; then
100 COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
107 # ex: ts=4 sw=4 et filetype=sh