xkcdpass.bash-completion 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Programmable Bash command completion for the ‘xkcdpass’ command.
  2. # See the Bash manual “Programmable Completion” section.
  3. #
  4. # Copyright © 2015–2016 Ben Finney <ben+python@benfinney.id.au>
  5. # This is free software: you may copy, modify, and/or distribute this
  6. # work under the terms of the BSD 3-Clause license.
  7. # See the file ‘LICENSE.BSD’ for details.
  8. shopt -s progcomp
  9. _xkcdpass_completion () {
  10. COMPREPLY=()
  11. local cur="${COMP_WORDS[COMP_CWORD]}"
  12. local prev="${COMP_WORDS[COMP_CWORD-1]}"
  13. local opts="-h --help -V --verbose"
  14. opts+=" -w --wordfile -v --valid-chars -a --acrostic"
  15. opts+=" -n --numwords --min --max"
  16. opts+=" -c --count -d --delimiter"
  17. case "${prev}" in
  18. -w|--wordfile)
  19. COMPREPLY=( $(compgen -A file -- ${cur}) )
  20. ;;
  21. *)
  22. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  23. ;;
  24. esac
  25. }
  26. complete -F _xkcdpass_completion xkcdpass
  27. # Local variables:
  28. # coding: utf-8
  29. # mode: shell-script
  30. # End:
  31. # vim: fileencoding=utf-8 filetype=bash :