aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/gpg.bash
blob: f98cb1934548301901d2f41a9815eab6fa9daeca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Completion for gpg(1) with long options
_gpg() {

    # Bail if no gpg(1)
    hash gpg 2>/dev/null || return 1

    # Bail if not completing an option
    [[ ${COMP_WORDS[COMP_CWORD]} == --* ]] || return 1

    # Generate completion reply from gpg(1) options
    local option
    while read -r option ; do
        [[ $option == "${COMP_WORDS[COMP_CWORD]}"* ]] || continue
        COMPREPLY[${#COMPREPLY[@]}]=$option
    done < <(gpg --dump-options 2>/dev/null)
}

# bashdefault requires Bash >=3.0
complete -F _gpg -o bashdefault -o default gpg