summaryrefslogtreecommitdiffstats
path: root/completions/lz4
blob: 8e2a77758fcb11185e3914638efb04729d271522 (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
42
43
44
45
46
47
48
49
50
51
52
53
# lz4 completion                                           -*- shell-script -*-

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

    case $prev in
        -b)
            _comp_compgen_filedir
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        _comp_compgen -R help -- -h
        _comp_compgen -- -X '-*#*' -W \
            '${COMPREPLY+"${COMPREPLY[@]}"} -B{4..7} -i{1..9}'
        return
    fi

    local REPLY word xspec="*.?(t)lz4"
    _comp_count_args
    local args=$REPLY
    ((args > 2)) && return

    for word in "${words[@]}"; do
        case $word in
            -*[dt]*)
                case $args in
                    1) xspec="!"$xspec ;;
                    2) [[ $word == *t* ]] && return ;;
                esac
                break
                ;;
            -z)
                case $args in
                    1) xspec= ;;
                    2) xspec="!"$xspec ;;
                esac
                break
                ;;
        esac
    done

    _comp_compgen_tilde && return

    compopt -o filenames
    _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
    complete -F _comp_cmd_lz4 lz4 lz4c

# ex: filetype=sh