blob: 4aee26397919ef4519f1468585a218dcbe270bd3 (
plain)
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
|
# Debian apt-get(8) completion -*- shell-script -*-
_apt_get()
{
local cur prev words cword package
_init_completion -n ':=' || return
local special i
for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download|changelog) ]]; then
special=${words[i]}
break
fi
done
if [[ -v special ]]; then
case $special in
remove | autoremove | purge)
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
;;
source)
COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
$(compgen -W "$(apt-cache dumpavail |
awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur"))
;;
install)
if [[ $cur == */* ]]; then
_filedir deb
return
elif [[ $cur == *=* ]]; then
package="${cur%%=*}"
cur="${cur#*=}"
COMPREPLY=($(IFS=$'\n' compgen -W "$(
apt-cache --no-generate madison "$package" 2>/dev/null |
while IFS=' |' read -r _ version _; do
echo "$version"
done
)" \
-- "$cur"))
__ltrim_colon_completions "$cur"
return
fi
;;&
build-dep)
_filedir -d
[[ $cur != */* ]] || return
;;&
*)
COMPREPLY+=($(_xfunc apt-cache _apt_cache_packages))
;;
esac
return
fi
case $prev in
--help | --version | --option | -!(-*)[hvo])
return
;;
--config-file | -!(-*)c)
_filedir
return
;;
--target-release | --default-release | -!(-*)t)
COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \
's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \
-- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=($(compgen -W '--no-install-recommends --install-suggests
--download-only --fix-broken --ignore-missing --fix-missing
--no-download --quiet --simulate --just-print --dry-run --recon
--no-act --yes --assume-yes --assume-no --no-show-upgraded
--verbose-versions --host-architecture --build-profiles --compile
--build --ignore-hold --with-new-pkgs --no-upgrade --only-upgrade
--allow-downgrades --allow-remove-essential
--allow-change-held-packages --force-yes --print-uris --purge
--reinstall --list-cleanup --target-release --default-release
--trivial-only --no-remove --auto-remove --autoremove --only-source
--diff-only --dsc-only --tar-only --arch-only --indep-only
--allow-unauthenticated --no-allow-insecure-repositories
--allow-releaseinfo-change --show-progress --with-source --help
--version --config-file --option' -- "$cur"))
else
COMPREPLY=($(compgen -W 'update upgrade dist-upgrade
dselect-upgrade install remove purge source build-dep check
download clean autoclean autoremove changelog indextargets' \
-- "$cur"))
fi
} &&
complete -F _apt_get apt-get
# ex: filetype=sh
|