/bash_completion_lib/complete -o filenames/dpkg

http://github.com/brinkman83/bashrc · #! · 76 lines · 67 code · 9 blank · 0 comment · 0 complexity · c2734652c3225473d67269ed77e60a73 MD5 · raw file

  1. # Debian dpkg(8) completion
  2. comp_include _comp_dpkg_installed_packages _expand _filedir _get_cword
  3. _dpkg()
  4. {
  5. local cur prev i
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. i=$COMP_CWORD
  10. _expand || return 0
  11. # find the last option flag
  12. if [[ $cur != -* ]]; then
  13. while [[ $prev != -* && $i != 1 ]]; do
  14. i=$((i-1))
  15. prev=${COMP_WORDS[i-1]}
  16. done
  17. fi
  18. case "$prev" in
  19. -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
  20. _filedir '?(u)deb'
  21. return 0
  22. ;;
  23. -@(b|-build))
  24. _filedir -d
  25. return 0
  26. ;;
  27. -@(s|p|l|-@(status|print-avail|list)))
  28. COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null ) )
  29. return 0
  30. ;;
  31. -@(S|-search))
  32. _filedir
  33. return 0
  34. ;;
  35. -@(r|L|P|-@(remove|purge|listfiles)))
  36. COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  37. return 0
  38. ;;
  39. *)
  40. COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
  41. --configure -r --remove -P --purge --get-selections \
  42. --set-selections --update-avail --merge-avail \
  43. --clear-avail --command-fd --forget-old-unavail -s \
  44. --status -p --print-avail -L --listfiles -l --list \
  45. -S --search -C --audit --print-architecture \
  46. --print-gnu-build-architecture \
  47. --print-installation-architecture \
  48. --compare-versions --help --version --force-help \
  49. --force-all --force-auto-select --force-downgrade \
  50. --force-configure-any --force-hold --force-bad-path \
  51. --force-not-root --force-overwrite \
  52. --force-overwrite-diverted --force-bad-verify \
  53. --force-depends-version --force-depends \
  54. --force-confnew --force-confold --force-confdef \
  55. --force-confmiss --force-conflicts --force-architecture\
  56. --force-overwrite-dir --force-remove-reinstreq \
  57. --force-remove-essential -Dh \
  58. --debug=help --licence --admindir= --root= --instdir= \
  59. -O --selected-only -E --skip-same-version \
  60. -G --refuse-downgrade -B --auto-deconfigure \
  61. --no-debsig --no-act -D --debug= --status-fd \
  62. -b --build -I --info -f --field -c --contents \
  63. -x --extract -X --vextract --fsys-tarfile -e --control \
  64. --ignore-depends= --abort-after' -- $cur ) )
  65. ;;
  66. esac
  67. } # _dpkg()