微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Git自动补全配置安装Mac版本

首先要安装 bash-completion,看一下自己的bash命令是否可以补全,如果不行要先安装bash-completion

brew install bash-completion
下载git源码
使用如下命令即可下载

git clone https://github.com/git/git
复制 git-completion.bash
代码下有个 contrib/completion 目录,有个 git-completion.bash 文件

cd git/contrib/completion/
将该文件复制到主目录(~)下。注意:复制时,文件名前加一个"点"(.),命令如下:
cp git-completion.bash ~/.git-completion.bash
修改主目录下的 .bashrc 文件(如果没有该文件,新建一个)。添加一行代码
source ~/.git-completion.bash
 

将下面代码添加到~/.bash_profile(如果没有该文件,新建一个)。

# git auto completition
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
然后,source一下使其生效

source ~/.git-completion.bash
source ~/.bash_profile
这样就可以,按下Tab键就可以提示啦。(如果还不可以,重启终端试试)

$ git che
checkout cherry cherry-pick

 

切换mac shell:

https://support.apple.com/zh-cn/HT208050

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐