`
sundful
  • 浏览: 1227966 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Mac下git命令自动补全

 
阅读更多

直接进入正题:

$ brew list

查看你是否已经安装了"bash-completion",如果没有,继续往下看:

$ brew install bash-completion
#####安装完成之后######
$ brew info bash-completion  
#####下边这句话很重要#######
==> Caveats
Add the following lines to your ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi

将if...then...那一句添加到~/.bash_profile(如果没有该文件,新建一个)

重启终端,以上为安装bash-completion部分。

接下来将git源码clone到本地

$ git clone https://github.com/git/git.git

找到"contrib/completion/"目录下的git-completion.bash,将该文件拷贝到~/下并重命名为.git-completion.bash

$ cp git-completion.bash ~/.git-completion.bash

在~/.bashrc文件(该目录下如果没有,新建一个)中添加下边的内容

source ~/.git-completion.bash

好了,重启终端以后就大功告成了

$ git --h[tab][tab] --help --html-path
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics