bash Mac OS X 终端中的自动完成——自定义单词列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21498712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Auto-Completion in Mac OS X Terminal – custom word list
提问by Pwdr
I would like to auto-complete the arguments in my function foo
. I want to store a list of possible arguments like this: bar,baba,gugu
.
我想自动完成我的函数中的参数foo
。我想存储的这样可能的参数列表:bar,baba,gugu
。
So when I type foo b[TAB]
in Terminal, I would like to have the recommendations of bar
and baba
.
因此,当我输入foo b[TAB]
Terminal 时,我希望得到bar
和的建议baba
。
回答by cody
Here you go: http://freecode.com/projects/bashcompletion
给你:http: //freecode.com/projects/bashcompletion
You can install it via brew: brew install bash-completion
. During installation brew will say what to do next - add some lines to your ~/.bash_profile:
您可以通过 brew: 安装它brew install bash-completion
。在安装过程中 brew 会说接下来要做什么 - 在你的 ~/.bash_profile 中添加一些行:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Take a look at READMEfor instructions on how to add custom completions
查看README以获取有关如何添加自定义完成的说明