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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:25:47  来源:igfitidea点击:

Auto-Completion in Mac OS X Terminal – custom word list

macosbashautocompleteterminal

提问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 barand 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以获取有关如何添加自定义完成的说明