PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 0ms RepoModel.GetById 40ms app.codeStats 0ms

/bash_completion.d/rfkill

http://github.com/brinkman83/bashrc
#! | 38 lines | 34 code | 4 blank | 0 comment | 0 complexity | 5386d19a8a01463babc710cd7b3b3007 MD5 | raw file
 1# bash completion for rfkill
 2
 3have rfkill &&
 4_rfkill()
 5{
 6    local cur prev
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10
11    if [[ "$cur" == -* ]]; then
12        COMPREPLY=( $( compgen -W '--version' -- "$cur" ) )
13    else
14        case $COMP_CWORD in
15            1)
16                COMPREPLY=( $( compgen -W "help event list block unblock" \
17                    -- "$cur" ) )
18                ;;
19            2)
20                prev=${COMP_WORDS[COMP_CWORD-1]}
21                if [ $prev == block -o $prev == unblock ]; then
22                    COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \
23                        '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \
24                        wwan gps" -- "$cur" ) )
25                fi
26                ;;
27        esac
28    fi
29} &&
30complete -F _rfkill rfkill
31
32# Local variables:
33# mode: shell-script
34# sh-basic-offset: 4
35# sh-indent-comment: t
36# indent-tabs-mode: nil
37# End:
38# ex: ts=4 sw=4 et filetype=sh