使用@符号(compgen)从列表创建bash补全

时间:2018-09-27 12:43:08

标签: linux bash autocomplete compgen

我想进行自定义bash补全。在完成时带有“ @”符号,我不知道如何转义它们。完成工作直到出现@,然后停止完成。 我很乐意提供帮助。

_foo()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

opts="jim@john go@alpha"

COMPREPLY=( $(compgen -W ${opts} -- ${cur}) )
}
complete -o nospace -F _foo foo

0 个答案:

没有答案