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