Mac git 命令行配置自动补齐

1.安装brew

2.使用brew安装bash-completion(命令行输入:brew install bash-completion)

3.使用brew info bash-completion查看bash-completion的安装位置



将[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"(不同环境不一样,根据自己的来)这部分添加到环境变量~/.bash_profile中

vim ~/.bash_profile


图中红色部分

4.确认自己git版本号(git version 2.19.2)

git --version

https://raw.githubusercontent.com/git/git/v2.19.2/contrib/completion/git-completion.bash下载对应自己版本号的脚本

5.将git-completion.bash拷贝到/usr/local/opt/bash-completion/etc/bash_completion.d下面

执行:

brew unlink bash-completion

brew link bash-completion

重启终端完成

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容