summaryrefslogtreecommitdiffstats
path: root/completions/interdiff
blob: 6f56e33aee431ea45a5acf25c5173b77b06eb554 (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
# interdiff(1) completion                                  -*- shell-script -*-

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

    local noargopts='!(-*|*[Upd]*)'
    # shellcheck disable=SC2254
    case $prev in
        --unified | --strip-match | --drop-context | -${noargopts}[Upd])
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
        return
    fi

    local exts='@(?(d)patch|dif?(f))' word
    for word in "${words[@]}"; do
        if [[ $word == -@(z|-decompress) ]]; then
            exts+='?(.@(gz|bz2))'
            break
        fi
    done
    _comp_compgen_filedir "$exts"
} &&
    complete -F _comp_cmd_interdiff interdiff

# ex: filetype=sh