File: compctl.dpkg

package info (click to toggle)
zsh 5.3.1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,324 kB
  • ctags: 8,554
  • sloc: ansic: 104,868; sh: 6,584; perl: 813; makefile: 774; awk: 388; sed: 16
file content (92 lines) | stat: -rw-r--r-- 3,895 bytes parent folder | download | duplicates (11)
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
#############################################################################
# Dpkg completion control for zsh.
#
# NOTE: Completion for these commands (dpkg, dpkg-source, bug)
# are included # upstream as part of the new completion system.
# Seriously consider using that instead.
#
# Originally by Joey Hess <joey@kite.ml.org>, GPL copyright.
# Contributions and fixes from Karl Hegbloom, Fabien Ninoles,
# Gregor Hoffleit, Csaba Benedek, &c.
#
# Currently doesn't handle correctly:
#       Options after -D or --debug.
#       --force- and friends,--ignore-depends,--root= and friends.

# A function to return all available package names.
# This could be done without grep and awk by replacing that line with
# reply=(${${(M)${(f)"$(</var/lib/dpkg/status)"}:#Package:*}#Package: })
function DpkgPackages {
        reply=(`grep '^Package:' /var/lib/dpkg/status | awk '{ print $2 }'`)
}

# This array lists all the dpkg options and actions.
dpkg_options=(-i --install --unpack --configure -r --remove --purge -A \
--avail --update-avail --merge-avail --yet-to-unpack -l --list -L \
--listfiles -C --audit -S --search -s --status --help -c --contents -I \
--info -B --auto-deconfigure -D --debug --largemem --smallmem --no-act \
-R --recursive -G -O --selected-only -E -e --control --skip-same-version \
-x --extract -f --field --fsys-tarfile -X --vextract --licence --version \
-b --build)

# This string lists all dpkg actions that operate on *.deb files, 
# separated by |'s. There can't be any extra whitespace in it!
dpkg_deb_actions="-i|--install|--unpack|-A|--avail|-c|--contents|-I|--info|-e"
dpkg_deb_actions="$dpkg_deb_actions|--control|-x|--extract|-f|--field"
dpkg_deb_actions="$dpkg_deb_actions|--fsys-tarfile|-X|--vextract|-info"

# This string lists all dpkg actions that normally operate on *.deb files,
# but can operate on directory names if the --recursive option is given to 
# dpkg.
dpkg_deb_rec_actions="-i|--install|--unpack|-A|--avail"

# This string lists all other dpkg actions that take a directory name as 
# their first parameter, and a filename as their second parameter.
dpkg_df_actions="-b|--build"

# This string lists dpkg actions that take a directory name as 
# their second parameter.
dpkg_dir2_actions="-e|--control|-x|--extract|--vextract"

# This string lists all dpkg actions that take a filename as their first
# parameter (ie, a Packages file).
dpkg_file_actions="-S|--search|--update-avail|--merge-avail"

# This string lists all dpkg actions that operate on the names of packages
# and can also be used with the --pending option.
dpkg_pkg_pending_actions="--configure|-r|--remove|--purge|-s|--status"

# This string lists all other dpkg actions that operate on the names of 
# packages.
dpkg_pkg_actions="-L|--listfiles|-s|--status|-l|--list"

# Now the command that puts it all together..
compctl -k dpkg_options \
  -x "C[-1,$dpkg_deb_rec_actions],R[-R|--recursive,]" -g '*(-/D)' \
  - "C[-1,$dpkg_deb_actions]" -g '*.deb' + -g '*(-/D)' \
  - "C[-1,$dpkg_pkg_pending_actions]" -K DpkgPackages + -k "(-a,--pending)" \
  - "C[-1,$dpkg_pkg_actions]" -K DpkgPackages \
  - "C[-1,$dpkg_file_actions],C[-2,$dpkg_df_actions]" -f \
  - "C[-2,$dpkg_dir2_actions],C[-1,$dpkg_df_actions]" -g '*(-/D)' \
  -- dpkg

# Also, set up package name completion for bug program.
compctl -K DpkgPackages bug

# This section by Karl M. Hegbloom

dpkg_source_options=(-x -b -c -l -F -V -T -D -U \
-sa -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR \
-h --help)

compctl -k dpkg_source_options \
 -x "C[-1,-x]" -g '*.dsc' \
 - "C[-1,-b]" -g '*(-/D)' \
 -- dpkg-source

# Unset the temporary variables.
unset dpkg_deb_actions dpkg_deb_rec_actions dpkg_df_actions \
        dpkg_dir2_actions dpkg_file_actions dpkg_pkg_pending_actions \
        dpkg_pkg_actions # dpkg_source_options dpkg_options

#############################################################################