PageRenderTime 43ms CodeModel.GetById 41ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

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