10

我用

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"

从数据库中获取可能的变体并使用TAB. 只要这些变体可以包含空格,使用'前缀和后缀自动引用它们是很方便的,所以当我按,A并且只有一个带有前缀的变体时,我会得到类似.BTABAB'ABC DEF'

但问题是,如果在,之后有很多变体A,我得到,然后我再按一次,它是 NOP,只有在第三次按下时,我才有可能完成。BTAB'ABTABTAB

有没有办法将TAB压力减少到一个或至少两个?

4

1 回答 1

12

你可以试试:

bind 'set show-all-if-ambiguous on'

来自man bash

   show-all-if-ambiguous (Off)
          This alters the default behavior of the completion functions.  If set 
          to on, words which have more than one possible completion cause the 
          matches to be listed immediately instead of ringing the bell.
于 2012-01-18T22:01:26.840 回答