]>
Commit | Line | Data |
---|---|---|
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') |
2bd3b27a SK |
9 | local DEV TYPE DEVICES='' |
10 | while read DEV TYPE; do | |
11 | [ $TYPE = 'part' ] && DEVICES+="$DEV " | |
12 | done < <(lsblk -pnro name,type) | |
13 | COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) | |
14 | return 0 | |
15 | ;; | |
675821f4 | 16 | '-b'|'--sector-size') |
2bd3b27a SK |
17 | COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) ) |
18 | return 0 | |
19 | ;; | |
675821f4 | 20 | '-c'|'--compatibility') |
2bd3b27a SK |
21 | COMPREPLY=( $(compgen -W "dos nondos" -- $cur) ) |
22 | return 0 | |
23 | ;; | |
675821f4 KZ |
24 | '-L'|'--color') |
25 | COMPREPLY=( $(compgen -W "auto never always" -- $cur) ) | |
26 | return 0 | |
27 | ;; | |
28 | '-u'|'--units') | |
2bd3b27a SK |
29 | COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) ) |
30 | return 0 | |
31 | ;; | |
675821f4 | 32 | '-C'|'--geom-cylinders'|'-H'|'--geom-heads'|'-S'|'--geom-sectors') |
2bd3b27a SK |
33 | COMPREPLY=( $(compgen -W "number" -- $cur) ) |
34 | return 0 | |
35 | ;; | |
675821f4 | 36 | '-h'|'--help'|'-v'|'--version'|'-V'|'--list') |
d4f9b8d7 VS |
37 | return 0 |
38 | ;; | |
2bd3b27a SK |
39 | esac |
40 | case $cur in | |
41 | -*) | |
675821f4 KZ |
42 | OPTS="--sector-size |
43 | --compatibility | |
44 | --color | |
45 | --list | |
46 | --type | |
47 | --units | |
48 | --getsz | |
49 | --geom-cylinders | |
50 | --geom-heads | |
51 | --geom-sectors | |
52 | --help | |
53 | --version" | |
2bd3b27a SK |
54 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
55 | return 0 | |
56 | ;; | |
57 | esac | |
58 | local DEV TYPE DEVICES='' | |
59 | while read DEV TYPE; do | |
60 | [ $TYPE = 'disk' ] && DEVICES+="$DEV " | |
61 | done < <(lsblk -pnro name,type) | |
62 | COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) | |
63 | return 0 | |
64 | } | |
65 | complete -F _fdisk_module fdisk |