Mac下git命令自动补全

默认在mac下安装的git命令是没有自动补全功能的,这在项目开发过程中显得有些不合时宜,so如何让git支持自动补全呢?

安装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

重启终端~

这篇文章目前没有评论

Leave a Reply

(必填项)

(必填项)

(可选)