This file is indexed.

/usr/share/bash-completion/completions/apt is in apt 1.6.6ubuntu0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Debian apt(8) completion                             -*- shell-script -*-

_apt()
{
    local sourcesdir="/etc/apt/sources.list.d"
    local cur prev words cword
    _init_completion || return

    local GENERIC_APT_GET_OPTIONS='
        -d --download-only
        -y --assume-yes
        --assume-no
        -u --show-upgraded
        -m --ignore-missing
        -t --target-release
        --download
        --fix-missing
        --ignore-hold
        --upgrade
        --only-upgrade
        --allow-change-held-packages
        --allow-remove-essential
        --allow-downgrades
        --print-uris
        --trivial-only
        --remove
        --arch-only
        --allow-unauthenticated
        --allow-insecure-repositories
        --install-recommends
        --install-suggests
        --fix-policy
    '

    # see if the user selected a command already
    local COMMANDS=(
        "list"
        "search"
        "show" "showsrc"
        "install" "remove" "purge" "autoremove"
        "update"
        "upgrade" "full-upgrade" "dist-upgrade"
        "edit-sources"
        "help"
        "source" "build-dep"
        "clean" "autoclean"
        "download" "changelog"
        "moo"
        "depends" "rdepends"
        "policy")

    local command i
    for (( i=0; i < ${#words[@]}-1; i++ )); do
        if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
            command=${words[i]}
            break
        fi
    done

    # Complete a -t<SPACE><TAB>
    case $prev in
        -t|--target-release)
            COMPREPLY=( $( compgen -W "$(apt-cache policy | egrep -o 'a=[^,]*|n=[^,]*' | cut -f2- -d= | sort -u)" -- "$cur" ) )
            return 0
            ;;
    esac

    # supported options per command
    if [[ "$cur" == -* ]]; then
        case $command in
            install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
                COMPREPLY=( $( compgen -W '--show-progress
                  --fix-broken --purge --verbose-versions --auto-remove
                  -s --simulate --dry-run
                  --download
                  --fix-missing
                  --fix-policy
                  --ignore-hold
                  --force-yes
                  --trivial-only
                  --reinstall --solver
                  -t --target-release'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
                return 0
                ;;
            update)
                COMPREPLY=( $( compgen -W '--list-cleanup
                  --print-uris
                  --allow-insecure-repositories
                  ' -- "$cur" ) )
                return 0
                ;;
            list)
                COMPREPLY=( $( compgen -W '--installed --upgradable 
                  --manual-installed
                  -v --verbose
                  -a --all-versions
                  -t --target-release
                  ' -- "$cur" ) )
                return 0
                ;;
            show)
                COMPREPLY=( $( compgen -W '-a --all-versions
                  ' -- "$cur" ) )
                return 0
                ;;
            depends|rdepends)
                COMPREPLY=( $( compgen -W '-i
                    --important
                    --installed
                    --pre-depends
                    --depends
                    --recommends
                    --suggests
                    --replaces
                    --breaks
                    --conflicts
                    --enhances
                    --recurse
                    --implicit' -- "$cur" ) )
                return 0
                ;;
            search)
                COMPREPLY=( $( compgen -W '
                    -n --names-only
                    -f --full' -- "$cur" ) )
                return 0
                ;;
            showsrc)
                COMPREPLY=( $( compgen -W '
                    --only-source' -- "$cur" ) )
                return 0
                ;;
            source)
                COMPREPLY=( $( compgen -W '
                    -s --simulate --dry-run
                    -b --compile --build
                    -P --build-profiles
                    --diff-only --debian-only
                    --tar-only
                    --dsc-only
                    -t --target-release
                    '"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
                return 0
                ;;
            build-dep)
                COMPREPLY=( $( compgen -W '
                    -a --host-architecture
                    -s --simulate --dry-run
                    -P --build-profiles
                    -t --target-release
                    --purge --solver
                    '"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
                return 0
                ;;
            moo)
                COMPREPLY=( $( compgen -W '
                    --color
                    ' -- "$cur" ) )
                return 0
                ;;
            clean|autoclean)
                COMPREPLY=( $( compgen -W '
                    -s --simulate --dry-run
                    ' -- "$cur" ) )
                return 0
                ;;
        esac
    fi

    # specific command arguments
    if [[ -n $command ]]; then
        case $command in
            remove|purge|autoremove)
                if [[ -f /etc/debian_version ]]; then
                    # Debian system
                    COMPREPLY=( $( \
                        _xfunc dpkg _comp_dpkg_installed_packages $cur ) )
                else
                    # assume RPM based
                    _xfunc rpm _rpm_installed_packages
                fi
                return 0
                ;;
            show|list|download|changelog|depends|rdepends)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) )
                return 0
                ;;
            install)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) )
                if [[ "$cur" == ./* || "$cur" == /* ]]; then
                    _filedir "deb"
                fi
                return 0
                ;;
            source|build-dep|showsrc|policy)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) $( apt-cache dumpavail | \
                    command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
                return 0
                ;;
            edit-sources)
                COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \
                    -- "$cur" ) )
                return 0
                ;;
            moo)
                COMPREPLY=( $( compgen -W 'moo' \
                    -- "$cur" ) )
                return 0
                ;;
        esac
    fi

    # no command yet, show what commands we have
    if [ "$command" = "" ]; then
        COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
    fi

    return 0
} &&
complete -F _apt apt

# ex: ts=4 sw=4 et filetype=sh