/bash_completion.d/apt-show-versions

http://github.com/brinkman83/bashrc · #! · 51 lines · 46 code · 5 blank · 0 comment · 0 complexity · fa1d3d49e31d9ec2a7620bda126f75d1 MD5 · raw file

  1. #-*-shell-script-*-
  2. have apt-show-versions &&
  3. _apt_show_versions()
  4. {
  5. local cur prev opts
  6. COMPREPLY=()
  7. cur="${COMP_WORDS[COMP_CWORD]}"
  8. if [[ "$cur" == --*=* ]]
  9. then
  10. prev="${cur%=*}"
  11. cur="${cur##*=}"
  12. else
  13. prev="${COMP_WORDS[COMP_CWORD-1]}"
  14. fi
  15. opts="-a --allversions -b --brief -h --help -i --initialize -ld --list-dir"
  16. opts="$opts -nh --nohold -p --package -r --regex -stf --status-file"
  17. opts="$opts -u --upgradeable -v --verbose"
  18. # Look for options needing an argument.
  19. # The used completion functions are defined in /etc/bash_completion.
  20. case "$prev" in
  21. -ld|--list-dir)
  22. _filedir -d
  23. return 0
  24. ;;
  25. -p|--package)
  26. COMPREPLY=( $(_comp_dpkg_installed_packages $cur) )
  27. return 0
  28. ;;
  29. -stf|--status-file)
  30. _filedir
  31. return 0
  32. ;;
  33. *)
  34. ;;
  35. esac
  36. # Look for options without an argument.
  37. if [[ "$cur" == -* ]]
  38. then
  39. COMPREPLY=( $(compgen -W "$opts" -- $cur) )
  40. return 0
  41. else
  42. COMPREPLY=( $(_comp_dpkg_installed_packages $cur) )
  43. return 0
  44. fi
  45. }
  46. complete -F _apt_show_versions -o filenames apt-show-versions