centos下Git颜色显示以及自动提示

之前一直在用Ubuntu和Windows上使用git,git的颜色显示和命令补全功能都能提升效率。现在换到centos上后,竟然没有了这两功能,倍感不爽。其实可以通过简答的配置,让它回来。

颜色设置

修改~/.gitconfig,添加下面内容。

1
2
3
4
[color]
diff = auto
status = auto
branch = auto

命令补齐

git的命令补齐脚本其实已经存在/etc/bash_completion.d/git,只要source以下这个文件就行。也可以写在/etc/profile或者~/.bashrc。笔者喜欢新建个/etc/profile.d/git.sh,然后在文件中写上

1
source /etc/bash_completion.d/git
显示 Gitment 评论