Mac 中 Git 命令自动补全

转战iOS开发已经有一段时间了,现在使用Mac,对于命令行的使用,真的是越来越喜欢,但是,在使用Git命令的时候,不能使用【Tab】来自动补全,为此,博主找寻方法,来完善Git命令补全功能。 ### 安装Homebrew 使用Homebrew安装的git,如何安装Honebrew及其使用在此就跳过,烦请自行查看(http://brew.sh/index_zh-cn.html)。 ### 安装bash-completion $ 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(如果没有该文件,新建一个) ### 获取git-completion.bash 将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 #### 配置git-completion.bash 在~/.bash_profile文件(该目录下如果没有,新建一个)中添加下边的内容 source ~/.git-completion.bash 重启终端即可 $ git --h[tab][tab] --help --html-path
联系我们

邮箱 626512443@qq.com
电话 18611320371(微信)
QQ群 235681453

Copyright © 2015-2022

备案号:京ICP备15003423号-3