Why don't git colors show up in iTerm2

2019-03-09 01:26发布

So I have my gitconfig setup to do colors. In Terminal it works great, looks fine.

In iTerm2, however, the colors don't appear for my gitconfig at all unless I set the reverse property for git. Then they appear but who likes reversed colors anyways?

Why does this happen and how can I fix it?

标签: git bash iterm
3条回答
一夜七次
2楼-- · 2019-03-09 01:40

You should check that iTerm is setting the TERM variable correctly. On my system, I see:

echo $TERM
xterm-256color

And have working colours in git. This is set according to the 'Report Terminal Type' property in iTerm's preferences.

here's a screenshot of iTerm 2's preferences

You should also check the Colors tab, and ensure the contrast slider isn't all the way to the right.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-03-09 01:44

I found an answer to this via http://code.google.com/p/iterm2/issues/detail?id=1639 that works for me.

"The solution is to add this to your ~/.gitconfig "

[core]
    pager = less -R
查看更多
仙女界的扛把子
4楼-- · 2019-03-09 02:03

In my case I had coloured output from other terminal applications in iTerm, just not git. For anyone still looking to solve this, what did it for me was the solution from http://buildamodule.com/forum/post/iterm-git-ui-colors.

Modify your global git config as follows:

git config --global color.ui true

查看更多
登录 后发表回答