Quick Start
一 、安装 bash-completion
1 | $ brew install bash-completion |
将if…then…那一句添加到~/.bash_profile(如果没有该文件,新建一个)
重启终端
二、拷贝文件、设置路径
访问网站 https://github.com/git/git.git
找到 ”contrib/completion/” 目录下的git-completion.bash ,
然后点击编辑,拷贝其内容,复制到文本文件,保存为 git-completion.bash 文件
然后将文件用命令拷贝到 ~/ 目录下1
$ cp xxx/git-completion.bash ~/.git-completion.bash
xxx 为文件所在目录,注意拷贝后的文件名称为 .git-completion.bash
在~/.bashrc文件(该目录下如果没有,新建一个)中添加下边的内容1
$ source ~/.git-completion.bash
三、 启动: 终端输入
1 | $ source ~/.git-completion.bash |
将下面这句话 添加到~/.bash_profile
1 | if [ -f ~/.git-completion.bash ]; then |
不添加想要补全起作用,每次都需要执行
source ~/.git-completion.bash
补全才能生效