]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/chcpu
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / chcpu
CommitLineData
c6f8c3f5
SK
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')
b5b80e5a
BE
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
c6f0bdfe 15 CPULIST="$WORD ${CPULIST:-""}"
b5b80e5a
BE
16 fi
17 done
18 compopt -o nospace
19 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
c6f8c3f5
SK
20 return 0
21 ;;
22 '-d'|'--disable')
b5b80e5a
BE
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
c6f0bdfe 29 CPULIST="$WORD ${CPULIST:-""}"
b5b80e5a
BE
30 fi
31 done
32 compopt -o nospace
33 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
c6f8c3f5
SK
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 ;;
d4f9b8d7
VS
44 '-h'|'--help'|'-V'|'--version')
45 return 0
46 ;;
c6f8c3f5 47 esac
0d5b9b8a
VS
48 OPTS="--help
49 --enable
50 --disable
51 --configure
52 --deconfigure
53 --dispatch
54 --rescan
55 --version"
c6f8c3f5
SK
56 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
57 return 0
58}
59complete -F _chcpu_module chcpu