]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/zramctl
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / zramctl
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')
9 COMPREPLY=( $(compgen -W "lzo lz4 lz4hc deflate 842" -- $cur) )
10 return 0
11 ;;
12 '-o'|'--output')
13 local prefix realcur OUTPUT_ALL OUTPUT
14 realcur="${cur##*,}"
15 prefix="${cur%$realcur}"
16 OUTPUT_ALL="NAME DISKSIZE DATA COMPR ALGORITHM
17 STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED
18 MIGRATED MOUNTPOINT"
19 for WORD in $OUTPUT_ALL; do
20 if ! [[ $prefix == *"$WORD"* ]]; then
21 OUTPUT="$WORD ${OUTPUT:-""}"
22 fi
23 done
24 compopt -o nospace
25 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
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
44 --output-all
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 }
60 complete -F _zramctl_module zramctl