]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/zramctl
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / zramctl
CommitLineData
2b0c19b0
SK
1_zramctl_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 '-a'|'--algorithm')
c50ad324 9 COMPREPLY=( $(compgen -W "lzo lz4 lz4hc deflate 842" -- $cur) )
2b0c19b0
SK
10 return 0
11 ;;
12 '-o'|'--output')
b5b80e5a
BE
13 local prefix realcur OUTPUT_ALL OUTPUT
14 realcur="${cur##*,}"
15 prefix="${cur%$realcur}"
d092911b
SK
16 OUTPUT_ALL="NAME DISKSIZE DATA COMPR ALGORITHM
17 STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED
18 MIGRATED MOUNTPOINT"
b5b80e5a
BE
19 for WORD in $OUTPUT_ALL; do
20 if ! [[ $prefix == *"$WORD"* ]]; then
abbcec4f 21 OUTPUT="$WORD ${OUTPUT:-""}"
b5b80e5a
BE
22 fi
23 done
2b0c19b0 24 compopt -o nospace
b5b80e5a 25 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
2b0c19b0
SK
26 return 0
27 ;;
28 '-s'|'--size')
29 COMPREPLY=( $(compgen -W "size" -- $cur) )
30 return 0
31 ;;
32 '-t'|'--streams')
33 COMPREPLY=( $(compgen -W "number" -- $cur) )
34 return 0
35 ;;
36 esac
37 case $cur in
38 -*)
39 OPTS=" --algorithm
40 --bytes
41 --find
42 --noheadings
43 --output
2e7ccec7 44 --output-all
2b0c19b0
SK
45 --raw
46 --reset
47 --size
48 --streams
49 --help
50 --version"
51 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
52 return 0
53 ;;
54 esac
55 local IFS=$'\n'
56 compopt -o filenames
57 COMPREPLY=( $(compgen -f -- ${cur:-"/dev/zram"}) )
58 return 0
59}
60complete -F _zramctl_module zramctl