美文网首页安装教程
Git命令自动补全(mac)

Git命令自动补全(mac)

作者: 我爱WSP | 来源:发表于2016-06-23 09:37 被阅读995次

请参照以下步骤##

  • 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.在~/.bashrc文件(如果没有就新建一个)中添加如下内容
source ~/.git-completion.bash

重启终端就可以了##

$ git remote [tab]
add            remove         set-branches   set-url        update         
prune          rename         set-head       show 

相关文章

网友评论

本文标题:Git命令自动补全(mac)

本文链接:https://www.haomeiwen.com/subject/wpvndttx.html