summaryrefslogtreecommitdiffstats
path: root/completions/chgrp
blob: 4793a45779a580c73e841b6a789eb9baabc6c949 (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
# chgrp(1) completion                                      -*- shell-script -*-

_chgrp()
{
    local cur prev words cword split
    _init_completion -s || return

    cur=${cur//\\\\/}

    if [[ $prev == --reference ]]; then
        _filedir
        return
    fi

    $split && return

    # options completion
    if [[ $cur == -* ]]; then
        local w opts
        for w in "${words[@]}"; do
            [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break
        done
        COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference
            --no-dereference --silent --quiet --reference --recursive --verbose
            --help --version $opts' -- "$cur"))
        return
    fi

    # first parameter on line or first since an option?
    if [[ $cword -eq 1 && $cur != -* || $prev == -* ]]; then
        _allowed_groups "$cur"
    else
        _filedir
    fi

} &&
    complete -F _chgrp chgrp

# ex: filetype=sh