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
10 local COMMANDS=("install" "remove" "purge" "show" "list"
11 "update" "upgrade" "full-upgrade" "dist-upgrade"
12 "edit-sources" "help")
15 for (( i=0; i < ${#words[@]}-1; i++ )); do
16 if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
22 # supported options per command
23 if [[ "$cur" == -* ]]; then
25 install|remove|purge|upgrade|full-upgrade)
26 COMPREPLY=( $( compgen -W '--show-progress
27 --fix-broken --purge --verbose-versions --auto-remove
35 --reinstall --solver' -- "$cur" ) )
39 COMPREPLY=( $( compgen -W '--list-cleanup
44 COMPREPLY=( $( compgen -W '--installed --upgradable
52 COMPREPLY=( $( compgen -W '-a --all-versions
59 # specific command arguments
60 if [[ -n $command ]]; then
63 if [[ -f /etc/debian_version ]]; then
66 _xfunc dpkg _comp_dpkg_installed_packages $cur ) )
69 _xfunc rpm _rpm_installed_packages
74 COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
79 COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \
86 # no command yet, show what commands we have
87 if [ "$command" = "" ]; then
88 COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
95 # ex: ts=4 sw=4 et filetype=sh