| 1 |
_genfstab() { |
| 2 |
compopt -o dirnames |
| 3 |
local cur prev words cword |
| 4 |
_init_completion || return |
| 5 |
|
| 6 |
local opts="-f -L -p -P -t -U -h" |
| 7 |
|
| 8 |
case ${prev} in |
| 9 |
-f) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
-t) |
| 13 |
COMPREPLY=($(compgen -W "LABEL UUID PARTLABEL PARTUUID" -- "${cur}")) |
| 14 |
return 0 |
| 15 |
;; |
| 16 |
esac |
| 17 |
|
| 18 |
if [[ ${cur} = -* ]]; then |
| 19 |
COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
| 20 |
return 0 |
| 21 |
fi |
| 22 |
|
| 23 |
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do |
| 24 |
if [[ -d ${i} ]]; then |
| 25 |
compopt +o dirnames |
| 26 |
return 0 |
| 27 |
fi |
| 28 |
done |
| 29 |
} |
| 30 |
|
| 31 |
complete -F _genfstab genfstab |