How to color the Git console in Ubuntu?

I recently saw that the Git console in Windows is colored, eg Green for additions, red for deletions, etc. How do I color my Ubuntu Git console like that?

To install it, I used the command: $ sudo apt-get install git-core


As noted by @VonC, color.ui defaults to auto since git 1.8.4. Not a release too soon ;)


From the Unix & Linux Stackexchange question How to colorize output of git? and the answer by @Evgeny:

git config --global color.ui auto

The color.ui is a meta configuration that includes all the various color.* configurations available with git commands. This is explained in-depth in git help config .

So basically it's easier and more future proof than setting the different color.* settings separately.

In-depth explanation from the git config documentation:

color.ui : This variable determines the default value for variables such as color.diff and color.grep that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the --color option. Set it to always if you want all output not intended for machine consumption to use color, to true or auto if you want such output to use color when written to the terminal, or to false or never if you prefer git commands not to use color unless enabled explicitly with some other configuration or the --color option.


For example see http://www.arthurkoziel.com/2008/05/02/git-configuration/

The interesting part is

Colorized output:

git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto

添加到你的.gitconfig文件的下一个代码:

  [color]
    ui = auto
  [color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
  [color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = green bold
  [color "status"]
    added = yellow
    changed = green
    untracked = cyan
链接地址: http://www.djcxy.com/p/15322.html

上一篇: 标准字体到网站?

下一篇: 如何在Ubuntu中着色Git控制台?