linux下 为自己编写的程序 添加tab自动补全 功能
生活随笔
收集整理的這篇文章主要介紹了
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-chen
cc@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等軟件 ^_^
轉載于:https://www.cnblogs.com/likeatree/p/5367158.html
總結
以上是生活随笔為你收集整理的linux下 为自己编写的程序 添加tab自动补全 功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 摩尔庄园手游机械狗有什么用?
- 下一篇: 求一个离婚纪念日的个性签名!