]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/sfdisk
Merge branch 'PR/losetup-json' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / bash-completion / sfdisk
1 _sfdisk_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 '-d'|'--dump'|'-J'|'--json'|'-l'|'--list'|'-F'|'--list-free'|'-r'|'--reorder'|'-s'|'--show-size'|'-V'|'--verify'|'-A'|'--activate'|'--delete')
9 compopt -o bashdefault -o default
10 COMPREPLY=( $(compgen -W "$(lsblk -dpnro name)" -- $cur) )
11 return 0
12 ;;
13 '-N'|'--partno')
14 COMPREPLY=( $(compgen -W "number" -- $cur) )
15 return 0
16 ;;
17 '--color'|'-w'|'--wipe'|'-W'|'--wipe-partitions')
18 COMPREPLY=( $(compgen -W "auto never always" -- $cur) )
19 return 0
20 ;;
21 '-o'|'--output')
22 local prefix realcur OUTPUT_ALL OUTPUT
23 realcur="${cur##*,}"
24 prefix="${cur%$realcur}"
25 OUTPUT_ALL="
26 Attrs Boot Bsize Cpg Cylinders Device End
27 End-C/H/S Flags Fsize Id Name Sectors Size
28 Slice Start Start-C/H/S Type Type-UUID UUID
29 "
30 for WORD in $OUTPUT_ALL; do
31 if ! [[ $prefix == *"$WORD"* ]]; then
32 OUTPUT="$WORD ${OUTPUT:-""}"
33 fi
34 done
35 compopt -o nospace
36 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- "$realcur") )
37 return 0
38 ;;
39 '-O'|'--backup-file')
40 local IFS=$'\n'
41 compopt -o filenames
42 COMPREPLY=( $(compgen -f -- $cur) )
43 return 0
44 ;;
45 '-h'|'--help'|'-v'|'--version')
46 return 0
47 ;;
48 esac
49 case $cur in
50 '=')
51 cur=${cur#=}
52 ;;
53 -*)
54 OPTS="
55 --activate
56 --dump
57 --json
58 --show-geometry
59 --list
60 --list-free
61 --disk-id
62 --reorder
63 --show-size
64 --list-types
65 --verify
66 --relocate
67 --delete
68 --part-label
69 --part-type
70 --part-uuid
71 --part-attrs
72 --append
73 --backup
74 --backup-pt-sectors
75 --bytes
76 --move-data
77 --force
78 --color
79 --lock
80 --partno
81 --no-act
82 --no-reread
83 --no-tell-kernel
84 --backup-file
85 --output
86 --quiet
87 --wipe
88 --wipe-partitions
89 --label
90 --label-nested
91 --help
92 --version
93 "
94 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
95 return 0
96 ;;
97 esac
98 compopt -o bashdefault -o default
99 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
100 return 0
101 }
102 complete -F _sfdisk_module sfdisk