summaryrefslogtreecommitdiffstats
path: root/completions/postmap
blob: 48e5d9f7586e2d11d8b40be36676e40b86499fba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# postalias(1) and postmap(1) completion                   -*- shell-script -*-

_comp_cmd_postmap()
{
    local cur prev words cword comp_args
    _comp_initialize -- "$@" || return

    case $prev in
        -c)
            _comp_compgen_filedir -d
            return
            ;;
        -[dq])
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        _comp_compgen_usage
        return
    fi

    if [[ $cur == *:* ]]; then
        compopt -o filenames
        _comp_compgen -c "${cur#*:}" -- -f
    else
        local len=${#cur} pval
        for pval in $(/usr/sbin/postconf -m 2>/dev/null); do
            if [[ $cur == "${pval:0:len}" ]]; then
                COMPREPLY+=("$pval:")
            fi
        done
        if [[ ! ${COMPREPLY-} ]]; then
            compopt -o filenames
            _comp_compgen -- -f
        fi
    fi
} &&
    complete -F _comp_cmd_postmap postmap postalias

# ex: filetype=sh