]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/zramctl
Merge branch 'master' of https://github.com/pali/util-linux
[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 --raw
45 --reset
46 --size
47 --streams
48 --help
49 --version"
50 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
51 return 0
52 ;;
53 esac
54 local IFS=$'\n'
55 compopt -o filenames
56 COMPREPLY=( $(compgen -f -- ${cur:-"/dev/zram"}) )
57 return 0
58 }
59 complete -F _zramctl_module zramctl