compgen: 用法:compgen [-abcdefgjksuv] [-o 选项] [-A 动作] [-G 全局模式] [-W 词语列表] [-F 函数] [-C 命令] [-X 过滤模式] [-P 前缀] [-S 后缀] [词语]
#compgen最常用的选项是-W,通过-W参数指定空格分隔的单词列表。h即我们在命令行Command-line当前键入的单词,执行完后会输出候选的匹配列表,这里是以h开头的所有单词 $ compgen -W 'hi hello how world' h hi hello how# 指定通过_test函数对test进行补全 $ function _test() > { > echo -e "\n" > declare -p COMP_WORDS > declare -p COMP_CWORD > declare -p COMP_LINE > declare -p COMP_WORDBREAKS > } $ complete -F _test test 再输入以下命令按补全: $ test adeclare -a COMP_WORDS=([0]="test" [1]="b") declare -- COMP_CWORD="1" declare -- COMP_LINE="test b" declare -- COMP_WORDBREAKS=" \"'><=;|&(:"
评论(0)
暂无评论