]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/fdisk
scriptreplay: cleanup usage()
[thirdparty/util-linux.git] / bash-completion / fdisk
CommitLineData
2bd3b27a
SK
1_fdisk_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
675821f4 8 '-s'|'--getsz')
53154dae 9 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
2bd3b27a
SK
10 return 0
11 ;;
675821f4 12 '-b'|'--sector-size')
2bd3b27a
SK
13 COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) )
14 return 0
15 ;;
675821f4 16 '-c'|'--compatibility')
2bd3b27a
SK
17 COMPREPLY=( $(compgen -W "dos nondos" -- $cur) )
18 return 0
19 ;;
675821f4
KZ
20 '-L'|'--color')
21 COMPREPLY=( $(compgen -W "auto never always" -- $cur) )
22 return 0
23 ;;
99d8ed0a
SK
24 '--output')
25 local prefix realcur OUTPUT_ALL OUTPUT
26 realcur="${cur##*,}"
27 prefix="${cur%$realcur}"
28 OUTPUT_ALL="
29 Attrs
30 Boot
31 Bsize
32 Cpg
33 Cylinders
34 Device
35 End
36 End-C/H/S
37 Flags
38 Fsize
39 Id
40 Name
41 Sectors
42 Size
43 Slice
44 Start
45 Start-C/H/S
46 Type
47 Type-UUID
48 UUID
49 "
50 for WORD in $OUTPUT_ALL; do
51 if ! [[ $prefix == *"$WORD"* ]]; then
abbcec4f 52 OUTPUT="$WORD ${OUTPUT:-""}"
99d8ed0a
SK
53 fi
54 done
55 compopt -o nospace
56 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- "$realcur") )
57 return 0
58 ;;
675821f4 59 '-u'|'--units')
2bd3b27a
SK
60 COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) )
61 return 0
62 ;;
99d8ed0a 63 '-C'|'--cylinders'|'-H'|'--heads'|'-S'|'--sectors')
2bd3b27a
SK
64 COMPREPLY=( $(compgen -W "number" -- $cur) )
65 return 0
66 ;;
675821f4 67 '-h'|'--help'|'-v'|'--version'|'-V'|'--list')
d4f9b8d7
VS
68 return 0
69 ;;
2bd3b27a
SK
70 esac
71 case $cur in
72 -*)
675821f4 73 OPTS="--sector-size
24bdce6e 74 --protect-boot
675821f4
KZ
75 --compatibility
76 --color
77 --list
99d8ed0a 78 --output
675821f4
KZ
79 --type
80 --units
81 --getsz
99d8ed0a
SK
82 --bytes
83 --wipe
84 --wipe-partitions
85 --cylinders
86 --heads
87 --sectors
675821f4
KZ
88 --help
89 --version"
2bd3b27a
SK
90 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
91 return 0
92 ;;
93 esac
6ead91ce 94 compopt -o bashdefault -o default
53154dae 95 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
2bd3b27a
SK
96 return 0
97}
98complete -F _fdisk_module fdisk