]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/chcpu
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / chcpu
1 _chcpu_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 '-e'|'--enable')
9 local prefix realcur CPULIST_ALL CPULIST
10 realcur="${cur##*,}"
11 prefix="${cur%$realcur}"
12 CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/offline)
13 for WORD in $(eval echo $CPULIST_ALL); do
14 if ! [[ $prefix == *"$WORD"* ]]; then
15 CPULIST="$WORD ${CPULIST:-""}"
16 fi
17 done
18 compopt -o nospace
19 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
20 return 0
21 ;;
22 '-d'|'--disable')
23 local prefix realcur CPULIST_ALL CPULIST
24 realcur="${cur##*,}"
25 prefix="${cur%$realcur}"
26 CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
27 for WORD in $(eval echo $CPULIST_ALL); do
28 if ! [[ $prefix == *"$WORD"* ]]; then
29 CPULIST="$WORD ${CPULIST:-""}"
30 fi
31 done
32 compopt -o nospace
33 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
34 return 0
35 ;;
36 '-c'|'--configure'|'-g'|'--deconfigure')
37 COMPREPLY=( $(compgen -W "cpu-list" -- $cur) )
38 return 0
39 ;;
40 '-p'|'--dispatch')
41 COMPREPLY=( $(compgen -W "horizontal vertical" -- $cur) )
42 return 0
43 ;;
44 '-h'|'--help'|'-V'|'--version')
45 return 0
46 ;;
47 esac
48 OPTS="--help
49 --enable
50 --disable
51 --configure
52 --deconfigure
53 --dispatch
54 --rescan
55 --version"
56 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
57 return 0
58 }
59 complete -F _chcpu_module chcpu