]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/fdisk
lsclocks: new util to interact with system clocks
[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
5adb0c90
SK
78 --list-details
79 --noauto-pt
80 --lock
99d8ed0a 81 --output
675821f4
KZ
82 --type
83 --units
84 --getsz
99d8ed0a
SK
85 --bytes
86 --wipe
87 --wipe-partitions
88 --cylinders
89 --heads
90 --sectors
675821f4
KZ
91 --help
92 --version"
2bd3b27a
SK
93 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
94 return 0
95 ;;
96 esac
6ead91ce 97 compopt -o bashdefault -o default
53154dae 98 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
2bd3b27a
SK
99 return 0
100}
101complete -F _fdisk_module fdisk