I use
cur="${COMP_WORDS[COMP_CWORD]}"
opts=`sqlite3 test.db "${QUERY[COMP_CWORD]}"`
SAVEIFS="$IFS"
IFS=$'\n'
COMPREPLY=( $(compgen -S"'" -P"'" -W "${opts}" $cur) )
IFS="$SAVEIFS"
to get possible variants from the database and complete them with TAB. As long as these variants could contain spaces, it is convinient to autoquote them using '
as prefix and suffix, so when I press A, B, TAB and there is only one variant with AB
prefix, then I get something like 'ABC DEF'
.
But the problem is that if there are many variants then after A, B, TAB I get 'AB
, then I press TAB once again and it is NOP, and only at the third TAB press I get possible completions.
Is there a way to reduce TAB pressings to one or at least two?