summaryrefslogtreecommitdiff
path: root/completions/sysctl
blob: 0ab3712906ce1cb3524b0421648627b393e9637f (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
# bash completion for sysctl                               -*- shell-script -*-

_sysctl()
{
    local cur prev words cword
    _init_completion || return

    case $prev in
        -p)
            _filedir conf
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
    else
        local suffix=
        [[ $prev == -w ]] && suffix==
        COMPREPLY=( $( compgen -S "$suffix" -W \
            "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ) )
        [[ $COMPREPLY == *= ]] && compopt -o nospace
    fi

    return 0
} &&
complete -F _sysctl sysctl

# ex: ts=4 sw=4 et filetype=sh