/bash_completion_lib/complete -o filenames/apt-build

http://github.com/brinkman83/bashrc · #! · 71 lines · 54 code · 17 blank · 0 comment · 0 complexity · 20895fd763d869fd0d694ce4a2e4dded MD5 · raw file

  1. # Debian apt-build(1) completion.
  2. comp_include _comp_dpkg_installed_packages _filedir _get_cword
  3. _apt_build()
  4. {
  5. local cur prev special i
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  10. if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
  11. special=${COMP_WORDS[i]}
  12. fi
  13. done
  14. if [ -n "$special" ]; then
  15. case $special in
  16. @(install|source|info))
  17. COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  18. return 0
  19. ;;
  20. remove)
  21. COMPREPLY=( $( _comp_dpkg_installed_packages \
  22. $cur ) )
  23. return 0
  24. ;;
  25. *)
  26. return 0
  27. ;;
  28. esac
  29. fi
  30. case "$prev" in
  31. --@(patch|build-dir|repository-dir))
  32. _filedir
  33. return 0
  34. ;;
  35. -@(h|-help))
  36. return 0
  37. ;;
  38. esac
  39. if [[ "$cur" == -* ]]; then
  40. COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
  41. --repository-dir --build-only \
  42. --build-command --reinstall --rebuild \
  43. --remove-builddep --no-wrapper --purge \
  44. --patch --patch-strip -p --yes -y \
  45. --version -v --no-source' -- $cur ) )
  46. else
  47. COMPREPLY=( $( compgen -W 'update upgrade install remove \
  48. source dist-upgrade world clean info \
  49. clean-build update-repository ' -- $cur ) )
  50. fi
  51. return 0
  52. }
  53. comp_install -F _apt_build # Make completion persistent for subsequent invocations
  54. _apt_build # Generate completions for first invocation