]>
Commit | Line | Data |
---|---|---|
9bf5e08f SK |
1 | _rfkill_module() |
2 | { | |
3 | local cur prev OPTS | |
4 | COMPREPLY=() | |
5 | cur="${COMP_WORDS[COMP_CWORD]}" | |
6 | prev="${COMP_WORDS[COMP_CWORD-1]}" | |
7 | case $prev in | |
33833562 | 8 | 'list'|'block'|'unblock'|'toggle') |
9bf5e08f SK |
9 | local targets |
10 | targets="$(rfkill --output=id,type --noheadings list)" | |
11 | COMPREPLY=( $(compgen -W "all $targets" -- $cur) ) | |
12 | return 0; | |
13 | ;; | |
14 | '-o'|'--output') | |
15 | local prefix realcur OUTPUT | |
16 | realcur="${cur##*,}" | |
17 | prefix="${cur%$realcur}" | |
18 | for WORD in "DEVICE TYPE ID SOFT HARD"; do | |
19 | if ! [[ $prefix == *"$WORD"* ]]; then | |
20 | OUTPUT="$WORD ${OUTPUT:-""}" | |
21 | fi | |
22 | done | |
23 | compopt -o nospace | |
24 | COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) | |
25 | return 0 | |
26 | ;; | |
27 | '-h'|'--help'|'-V'|'--version') | |
28 | return 0 | |
29 | ;; | |
30 | esac | |
31 | OPTS=" | |
32 | event | |
33 | list | |
34 | block | |
35 | unblock | |
33833562 | 36 | toggle |
9bf5e08f SK |
37 | --json |
38 | --noheadings | |
39 | --output | |
4dfd172d | 40 | --output-all |
9bf5e08f SK |
41 | --raw |
42 | --help | |
43 | --version | |
44 | " | |
45 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) | |
46 | return 0 | |
47 | ||
48 | } | |
49 | complete -F _rfkill_module rfkill |