]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/fdisk
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / fdisk
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
8 '-s'|'--getsz')
9 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
10 return 0
11 ;;
12 '-b'|'--sector-size')
13 COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) )
14 return 0
15 ;;
16 '-c'|'--compatibility')
17 COMPREPLY=( $(compgen -W "dos nondos" -- $cur) )
18 return 0
19 ;;
20 '-L'|'--color')
21 COMPREPLY=( $(compgen -W "auto never always" -- $cur) )
22 return 0
23 ;;
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
52 OUTPUT="$WORD ${OUTPUT:-""}"
53 fi
54 done
55 compopt -o nospace
56 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- "$realcur") )
57 return 0
58 ;;
59 '-u'|'--units')
60 COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) )
61 return 0
62 ;;
63 '-C'|'--cylinders'|'-H'|'--heads'|'-S'|'--sectors')
64 COMPREPLY=( $(compgen -W "number" -- $cur) )
65 return 0
66 ;;
67 '-h'|'--help'|'-v'|'--version'|'-V'|'--list')
68 return 0
69 ;;
70 esac
71 case $cur in
72 -*)
73 OPTS="--sector-size
74 --protect-boot
75 --compatibility
76 --color
77 --list
78 --output
79 --type
80 --units
81 --getsz
82 --bytes
83 --wipe
84 --wipe-partitions
85 --cylinders
86 --heads
87 --sectors
88 --help
89 --version"
90 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
91 return 0
92 ;;
93 esac
94 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
95 return 0
96 }
97 complete -F _fdisk_module fdisk