]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/sfdisk
Merge branch 'lsclocks/ns-offset' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / bash-completion / sfdisk
CommitLineData
2bd3b27a
SK
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
99d8ed0a 8 '-d'|'--dump'|'-J'|'--json'|'-l'|'--list'|'-F'|'--list-free'|'-r'|'--reorder'|'-s'|'--show-size'|'-V'|'--verify'|'-A'|'--activate'|'--delete')
6ead91ce 9 compopt -o bashdefault -o default
99d8ed0a
SK
10 COMPREPLY=( $(compgen -W "$(lsblk -dpnro name)" -- $cur) )
11 return 0
12 ;;
13 '-N'|'--partno')
2bd3b27a
SK
14 COMPREPLY=( $(compgen -W "number" -- $cur) )
15 return 0
16 ;;
99d8ed0a 17 '--color'|'-w'|'--wipe'|'-W'|'--wipe-partitions')
24bdce6e
SK
18 COMPREPLY=( $(compgen -W "auto never always" -- $cur) )
19 return 0
20 ;;
99d8ed0a
SK
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
abbcec4f 32 OUTPUT="$WORD ${OUTPUT:-""}"
99d8ed0a
SK
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')
ce3e6b15 40 local IFS=$'\n'
2bd3b27a
SK
41 compopt -o filenames
42 COMPREPLY=( $(compgen -f -- $cur) )
43 return 0
d4f9b8d7
VS
44 ;;
45 '-h'|'--help'|'-v'|'--version')
46 return 0
2bd3b27a
SK
47 ;;
48 esac
49 case $cur in
50 '=')
51 cur=${cur#=}
52 ;;
53 -*)
24bdce6e
SK
54 OPTS="
55 --activate
56 --dump
57 --json
58 --show-geometry
0d5b9b8a 59 --list
8abdb912 60 --list-free
5adb0c90 61 --disk-id
99d8ed0a 62 --reorder
24bdce6e 63 --show-size
0d5b9b8a 64 --list-types
0d5b9b8a 65 --verify
5adb0c90 66 --relocate
99d8ed0a 67 --delete
24bdce6e
SK
68 --part-label
69 --part-type
70 --part-uuid
71 --part-attrs
72 --append
73 --backup
c4762c43 74 --backup-pt-sectors
24bdce6e 75 --bytes
99d8ed0a 76 --move-data
0d5b9b8a 77 --force
24bdce6e 78 --color
5adb0c90 79 --lock
24bdce6e
SK
80 --partno
81 --no-act
2bd3b27a 82 --no-reread
99d8ed0a 83 --no-tell-kernel
24bdce6e
SK
84 --backup-file
85 --output
0d5b9b8a 86 --quiet
99d8ed0a
SK
87 --wipe
88 --wipe-partitions
24bdce6e
SK
89 --label
90 --label-nested
91 --help
92 --version
93 "
2bd3b27a
SK
94 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
95 return 0
96 ;;
97 esac
6ead91ce 98 compopt -o bashdefault -o default
53154dae 99 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
2bd3b27a
SK
100 return 0
101}
102complete -F _sfdisk_module sfdisk