]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/rfkill
Merge branch 'lsclocks/relative-time' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / bash-completion / rfkill
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
8 'list'|'block'|'unblock'|'toggle')
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
36 toggle
37 --json
38 --noheadings
39 --output
40 --output-all
41 --raw
42 --help
43 --version
44 "
45 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
46 return 0
47
48 }
49 complete -F _rfkill_module rfkill