7

I'm outputting to a terminal, but Git is not correctly detecting that I'm outputting to a terminal, for the purposes of coloring the output. My question is, what does git-config(1) really mean when it says "colors are used only when the output is to a terminal" (this phrase appears at the end of multiple config descriptions, such as for color.ui and color.branch)? In other words, how does Git decide whether or not it's outputting to a terminal, and how do I change my environment settings to inform Git that my terminal is indeed a terminal?

Specifics:
I'm using rxvt terminal with Cygwin on Windows. I also have MSysGit installed. When I make the Git config settings:

[color]
    ui = auto
    branch = auto
    status = auto

there is still no color in my terminal output. However, when I switch to

[color]
    ui = always
    branch = always
    status = always

then there is correct colored output. However, I need to switch back to "auto", not "always", in order to handle the actual non-terminal cases correctly. So for the purpose of making "auto" work correctly: How do I change my environment to make Git recognize that my rxvt+Cygwin is a terminal capable to supporting color?

(PS. I can't use the Cygwin version of Git due to much bigger problems than this relatively minor color issue. Please don't reply telling me to switch to the Cygwin version.)

Thanks for your help!

walrus
  • 2,945
  • 5
  • 18
  • 19
  • What is your `TERM` environment variable set to? (Check with `echo $TERM`.) – ezod Aug 26 '12 at 19:32
  • @ezod: I've tried changing TERM to a few different values, and it didn't have any effect. The current value (i.e. last value I tried) is "xterm-256color". – walrus Aug 26 '12 at 19:47

1 Answers1

2

It might be worth looking at this question which covers detecting difference between output going to a terminal (i.e. tty session) vs it being redirected to another process. I'm assuming that this is what git means in its phrasing of "going to a terminal", that the output is in fact going to a tty session.

Community
  • 1
  • 1
Mark Fisher
  • 9,838
  • 3
  • 32
  • 38
  • I just ran those tests in my terminal, and sure enough it was correctly detected as a terminal. So Git (well, MSysGit) is still the only thing I know of that doesn't think my terminal is a terminal. Sigh. – walrus Aug 26 '12 at 19:55