具体步骤如下:
-
1.安装bash-completion
brew info bash-completion
-
2.添加以下代码到**~/.bash_profile**
if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi
-
3.执行以下命令
source ~/.bash_profile
-
4.将git源码clone到本地
git clone https://github.com/git/git.git
-
5.执行以下命令
cp ./git/contrib/completion/git-completion.bash ~/.git-completion.bash
-
6.添加以下代码到**~/.bashrc**
source ~/.git-completion.bash
-
7.执行以下命令
source ~/.bashrc
至此就可以到自己的代码里使用git命令按’tab’键就会自动补全。