summaryrefslogtreecommitdiffstats
path: root/completions/xvfb-run
blob: 9ae1fc85ce127021205f02d0d6b49f7b17485553 (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
# bash completion for xvfb-run                             -*- shell-script -*-

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

    local noargopts='!(-*|*[npsef]*)'
    local i
    for ((i = 1; i <= cword; i++)); do
        if [[ ${words[i]} != -* ]]; then
            _comp_command_offset $i
            return
        fi
        # shellcheck disable=SC2254
        [[ ${words[i]} == -${noargopts}[npsef] ]] && ((i++))
    done

    # shellcheck disable=SC2254
    case $prev in
        --help | --server-num | --xauth-protocol | --server-args | -${noargopts}[hnps])
            return
            ;;
        --error-file | --auth-file | -${noargopts}[ef])
            _comp_compgen_filedir
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    fi
} &&
    complete -F _comp_cmd_xvfb_run xvfb-run

# ex: filetype=sh