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
|
#############################################################################
# Dpkg completion control for zsh.
#
# By Joey Hess <joey@kite.ml.org>, GPL copyright.
#
# 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.
function DpkgPackages {
reply=(`egrep ^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|-l"
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"
# 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
#############################################################################
|