引用自:https://www.jianshu.com/p/7130a5c11d42
请参照以下步骤##
- 1.查看是否已经安装了
bash-completion
,如果没有请使用以下命令安装brew install bash-completion
- 2.执行
brew info bash-completion
命令
$brew info bash-completion
Add the following lines to your ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi
- 3.将第二步中的if..then...fi语句添加到
~/.bash_profile
文件中(如果没有该文件,新建一个) - 4.重启终端
以上为安装bash-completion部分###
- 5.将Git源码clone到本地
$ git clone https://github.com/git/git.git
小提示:如果不希望clone整个项目,可以直接将项目中的contrib/completion/git-completion.bash
的内容拷贝出来保存到保存到~/.git-completion.bash
,该提示等效于第六步 - 6.找到
contrib/completion/git-completion.bash
,将该文件拷贝到~/
下并重命名为.git-completion.bash
$ cp git-completion.bash ~/.git-completion.bash
- 7.在
~/.bash_profile
文件(这里原作者应该是弄错了,如果没有就新建一个)中添加如下内容
source ~/.git-completion.bash
重启终端就可以了##
$ git remote [tab] add remove set-branches set-url update prune rename set-head show
转载请标明出处:mac git添加自动补全
文章来源: mac git添加自动补全