默认在mac下安装的git命令是没有自动补全功能的,这在项目开发过程中显得有些不合时宜,so如何让git支持自动补全呢?
2019年12月2日更新:
因最新版本的macOS Catalina 默认使用zsh作为其终端shell,故此文之前介绍的方法已经不再适用。
目前本人开始使用 Oh My Zsh,真香!
你可以查看我的文章 Oh My Zsh初体验 了解更多的Oh My Zsh的使用
安装bash-completion
brew install bash-completion
编辑~/.bash_profile
在文件结尾处添加如下代码:
if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi
安装git-completion.bash
cd $(brew --prefix)/etc/bash_completion.d curl -L -O https://raw.github.com/git/git/master/contrib/completion/git-completion.bash chmod a+x git-completion.bash
重启终端~
这篇文章目前没有评论