| 1 |
_mistral_opts="" # lazy init |
| 2 |
_mistral_flags="" # lazy init |
| 3 |
_mistral_opts_exp="" # lazy init |
| 4 |
_mistral() |
| 5 |
{ |
| 6 |
local cur prev mbc cflags |
| 7 |
COMPREPLY=() |
| 8 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 9 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 10 |
|
| 11 |
if [ "x$_mistral_opts" == "x" ] ; then |
| 12 |
mbc="`mistral bash-completion`" |
| 13 |
_mistral_opts="`echo "$mbc" | sed -e "s/\s-[a-z0-9_-]*//g" -e "s/\s\s*/ /g"`" |
| 14 |
_mistral_flags="`echo " $mbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/\s\s*/ /g"`" |
| 15 |
_mistral_opts_exp="`echo "$_mistral_opts" | sed -e "s/\s/|/g"`" |
| 16 |
fi |
| 17 |
|
| 18 |
if [[ " ${COMP_WORDS[@]} " =~ " "($_mistral_opts_exp)" " && "$prev" != "help" ]] ; then |
| 19 |
COMPREPLY=($(compgen -W "${_mistral_flags}" -- ${cur})) |
| 20 |
else |
| 21 |
COMPREPLY=($(compgen -W "${_mistral_opts}" -- ${cur})) |
| 22 |
fi |
| 23 |
return 0 |
| 24 |
} |
| 25 |
complete -F _mistral mistral |