/bash_completion_lib/complete -o default/gpg

http://github.com/brinkman83/bashrc · #! · 40 lines · 31 code · 9 blank · 0 comment · 0 complexity · 8b597e5d6f0550b5ea48ab53d8ac6679 MD5 · raw file

  1. # gpg(1) completion
  2. comp_include _filedir _get_cword
  3. _gpg()
  4. {
  5. local cur prev
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. case "$prev" in
  10. -@(s|-sign|-clearsign|-decrypt-files|-load-extension))
  11. _filedir
  12. return 0
  13. ;;
  14. --@(export|@(?(l|nr|nrl)sign|edit)-key))
  15. # return list of public keys
  16. COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ))
  17. return 0
  18. ;;
  19. -@(r|-recipient))
  20. COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
  21. if [ -e ~/.gnupg/gpg.conf ]; then
  22. COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf )" -- "$cur") )
  23. fi
  24. return 0
  25. ;;
  26. esac
  27. if [[ "$cur" == -* ]]; then
  28. COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
  29. -q -n -N $(gpg --dump-options)' -- $cur ) )
  30. fi
  31. } # _gpg()