Mac git命令自动补全

Mac git命令自动补全

 

https://www.csdn.net/tags/MtjaYgysMzQxMS1ibG9n.html

 

提前确保mac上安装好homebrew,homebrew是mac上的一包管理工具,这个不再此处展开,百度一下就👌

开始

用homebrew安装bash-completio

brew install brew install bash-completion

下载成功之后,再下载一个github上的git源码,需要去获取里面的一个bash文件,下载git源码

git clone git://git.kernel.org/pub/scm/git/git.git

在git源码中找到contrib/completion/git-completion.bash

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

修改文件,没有的话创建文件 ~/.bash_profile

if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash
fi

然后source下文件

source ~/.bash_profile

如果出现下面的错误:

WARNING: this script is deprecated, please see git-completion.zsh

这是mac默认的shell是zsh不是bash,修改成bash即可,修改方式如下:

随便打开一个终端 -> 左上角找到终端-偏好设置 -> Shell的打开方式修改为/bin/bash

再执行source ~/.bash_profile

然后git 补全就ok了!

 

posted @ 2022-05-19 11:11  sundaysandroid  阅读(590)  评论(0编辑  收藏  举报