| 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 "$(command 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 |
--list-details |
| 79 |
--noauto-pt |
| 80 |
--lock |
| 81 |
--output |
| 82 |
--type |
| 83 |
--units |
| 84 |
--getsz |
| 85 |
--bytes |
| 86 |
--wipe |
| 87 |
--wipe-partitions |
| 88 |
--cylinders |
| 89 |
--heads |
| 90 |
--sectors |
| 91 |
--help |
| 92 |
--version" |
| 93 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 94 |
return 0 |
| 95 |
;; |
| 96 |
esac |
| 97 |
compopt -o bashdefault -o default |
| 98 |
COMPREPLY=( $(compgen -W "$(command lsblk -pnro name)" -- $cur) ) |
| 99 |
return 0 |
| 100 |
} |
| 101 |
complete -F _fdisk_module fdisk |