200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > linux下 为自己编写的程序 添加tab自动补全 功能

linux下 为自己编写的程序 添加tab自动补全 功能

时间:2022-04-27 05:16:53

相关推荐

linux下 为自己编写的程序 添加tab自动补全 功能

linux下 为自己编写的程序 添加tab自动补全功能 入门

complete

在我的tmp下随便写了一个a.sh, 为他补全edit/etc/bash_completion.d/foo

_foo(){local cur prev optsCOMPREPLY=()cur="${COMP_WORDS[COMP_CWORD]}"prev="${COMP_WORDS[COMP_CWORD-1]}"opts="--help --verbose --version"if [[ ${cur} == -* ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )return 0fi}complete -F _foo /home/cc/tmp/comp/a.sh

source foo后

表现为

cc@PC:~/tmp/comp$ ./a.sh a.sh comp1.sh comp-a.sh x-chencc@PC:~/tmp/comp$ /home/cc/tmp/comp/a.sh ----help--verbose --version

4.undo以上操作???

我猜想是改一下步骤2的函数体继续做以下步骤就好

================================对x的complete完全正确步骤

edit/etc/bash_completion.d/xchencomp

_x_chen_comp() {local cur prev optsCOMPREPLY=()cur="${COMP_WORDS[COMP_CWORD]}"prev="${COMP_WORDS[COMP_CWORD-1]}"opts="qtcreator idea lantern clion"COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )return 0}complete -F _x_chen_comp x

source xchencomp

愉快使用x命令打开qtcreator等软件 ^_^

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。