]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/partx
Merge branch '2017wk28' of git://github.com/kerolasa/lelux-utiliteetit
[thirdparty/util-linux.git] / bash-completion / partx
1 _partx_module()
2 {
3 local cur prev OPTS OUTPUT_ALL
4 COMPREPLY=()
5 OUTPUT_ALL="NR START END SECTORS SIZE NAME UUID TYPE FLAGS SCHEME"
6 cur="${COMP_WORDS[COMP_CWORD]}"
7 prev="${COMP_WORDS[COMP_CWORD-1]}"
8 case $prev in
9 '-n'|'--nr')
10 return 0
11 ;;
12 '-o'|'--output')
13 local realcur prefix OUTPUT
14 realcur="${cur##*,}"
15 prefix="${cur%$realcur}"
16 for WORD in $OUTPUT_ALL; do
17 if ! [[ $prefix == *"$WORD"* ]]; then
18 OUTPUT="$WORD ${OUTPUT:-""}"
19 fi
20 done
21 compopt -o nospace
22 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
23 return 0
24 ;;
25 '-S'|'--sector-size')
26 COMPREPLY=( $(compgen -W "size" -- $cur) )
27 return 0
28 ;;
29 '-t'|'--type')
30 COMPREPLY=( $(compgen -W "$(partx --list-types)" -- $cur) )
31 return 0
32 ;;
33 '-h'|'--help'|'-V'|'--version')
34 return 0
35 ;;
36 esac
37 case $cur in
38 -*)
39 OPTS="
40 --add
41 --delete
42 --update
43 --show
44 --bytes
45 --noheadings
46 --nr
47 --output
48 --pairs
49 --raw
50 --sector-size
51 --type
52 --list-types
53 --verbose
54 --help
55 --version
56 "
57 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
58 return 0
59 ;;
60 esac
61 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
62 return 0
63 }
64 complete -F _partx_module partx