summaryrefslogtreecommitdiffstats
path: root/contrib/bash-completion
blob: 0c8fb78ad49fd9838eb4b20a1c55e468ae98ab58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# hostinfo completion

_hostinfo_hosts="$(for file in /usr/local/share/hostinfo/* ; do basename $file | sed 's/.spline.inf.fu-berlin.de//' ; done)"

_hostinfo() {
    local cur prev

    COMPREPLY=()
    _get_comp_words_by_ref cur prev

    _get_first_arg
    if [[ -z "$arg" ]]; then
        _completion="$_hostinfo_hosts"
    else
        _completion="$(hostinfo --keys $arg 2>/dev/null)"
    fi

    COMPREPLY=( $( compgen -W "-o --oneline -f --file -k --keys -h -? --help $_completion" -- $cur ) )
}
complete -F _hostinfo hostinfo