mac git添加自动补全

匿名 (未验证) 提交于 2019-12-02 23:00:14

引用自: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添加自动补全
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!