PageRenderTime 208ms CodeModel.GetById 116ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/bash_completion.d/wireless-tools

http://github.com/brinkman83/bashrc
#! | 183 lines | 161 code | 22 blank | 0 comment | 0 complexity | 9988c688308c497c3f4fb0acc571c470 MD5 | raw file
  1# bash completion for Linux wireless-tools
  2
  3[ $UNAME = Linux ] &&
  4{
  5
  6have iwconfig &&
  7_iwconfig()
  8{
  9    local cur prev
 10
 11    COMPREPLY=()
 12    cur=`_get_cword`
 13    prev=${COMP_WORDS[COMP_CWORD-1]}
 14
 15    case $prev in
 16        mode)
 17            COMPREPLY=( $( compgen -W 'managed ad-hoc master \
 18                repeater secondary monitor' -- "$cur" ) )
 19            return 0
 20            ;;
 21        essid)
 22            COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
 23            if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
 24                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
 25                    "$( iwlist ${COMP_WORDS[1]} scan | \
 26                    awk -F '\"' '/ESSID/ {print $2}' )" -- "$cur" ) )
 27            fi
 28            return 0
 29            ;;
 30        nwid)
 31            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
 32            return 0
 33            ;;
 34        channel)
 35            COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
 36                awk '/^[[:space:]]*Channel/ {print $2}' )" -- "$cur" ) )
 37            return 0
 38            ;;
 39
 40        freq)
 41            COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
 42                awk '/^[[:space:]]*Channel/ {print $4\"G\"}')" -- "$cur" ) )
 43            return 0
 44            ;;
 45        ap)
 46            COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
 47            if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
 48                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
 49                    "$( iwlist ${COMP_WORDS[1]} scan | \
 50                    awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) )
 51            fi
 52            return 0
 53            ;;
 54        rate)
 55            COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) )
 56            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
 57                "$( iwlist ${COMP_WORDS[1]} rate | \
 58                awk '/^[[:space:]]*[0-9]/ {print $1\"M\"}' )" -- "$cur" ) )
 59            return 0
 60            ;;
 61        rts|frag)
 62            COMPREPLY=( $( compgen -W 'auto fixed off' -- "$cur" ) )
 63            return 0
 64            ;;
 65        key|enc)
 66            COMPREPLY=( $( compgen -W 'off on open restricted' -- "$cur" ) )
 67            return 0
 68            ;;
 69        power)
 70            COMPREPLY=( $( compgen -W 'period timeout off on' -- "$cur" ) )
 71            return 0
 72            ;;
 73        txpower)
 74            COMPREPLY=( $( compgen -W 'off on auto' -- "$cur" ) )
 75            return 0
 76            ;;
 77        retry)
 78            COMPREPLY=( $( compgen -W 'limit lifetime' -- "$cur" ) )
 79            return 0
 80            ;;
 81    esac
 82
 83    if [ $COMP_CWORD -eq 1 ]; then
 84        if [[ "$cur" == -* ]]; then
 85            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
 86        else
 87            _available_interfaces -w
 88        fi
 89    else
 90        COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
 91            ap nick rate rts frag enc key power txpower commit' -- "$cur" ) )
 92    fi
 93
 94} &&
 95complete -F _iwconfig iwconfig
 96
 97
 98have iwlist &&
 99_iwlist()
100{
101    local cur prev
102
103    COMPREPLY=()
104    cur=`_get_cword`
105    prev=${COMP_WORDS[COMP_CWORD-1]}
106
107    if [ $COMP_CWORD -eq 1 ]; then
108        if [[ "$cur" == -* ]]; then
109            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
110        else
111            _available_interfaces -w
112        fi
113    else
114        COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
115            channel rate bit bitrate key enc encryption power \
116            txpower retry ap accesspoint peers event' -- "$cur" ) )
117    fi
118} &&
119complete -F _iwlist iwlist
120
121
122have iwspy &&
123_iwspy()
124{
125    local cur
126
127    COMPREPLY=()
128    cur=`_get_cword`
129
130    if [ $COMP_CWORD -eq 1 ]; then
131        if [[ "$cur" == -* ]]; then
132            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
133        else
134            _available_interfaces -w
135        fi
136    else
137        COMPREPLY=( $( compgen -W 'setthr getthr off' -- "$cur" ) )
138    fi
139} &&
140complete -F _iwspy iwspy
141
142
143have iwpriv &&
144_iwpriv()
145{
146    local cur prev
147
148    COMPREPLY=()
149    cur=`_get_cword`
150    prev=${COMP_WORDS[COMP_CWORD-1]}
151
152    case "$prev" in
153        roam)
154            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
155            return 0
156            ;;
157        port)
158            COMPREPLY=( $( compgen -W 'ad-hoc managed' -- "$cur" ) )
159            return 0
160            ;;
161    esac
162
163    if [ $COMP_CWORD -eq 1 ]; then
164        if [[ "$cur" == -* ]]; then
165            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
166        else
167            _available_interfaces -w
168        fi
169    else
170        COMPREPLY=( $( compgen -W '--all roam port' -- "$cur" ) )
171    fi
172} &&
173complete -F _iwpriv iwpriv
174
175}
176
177# Local variables:
178# mode: shell-script
179# sh-basic-offset: 4
180# sh-indent-comment: t
181# indent-tabs-mode: nil
182# End:
183# ex: ts=4 sw=4 et filetype=sh