git-config(1)是什么意思,当它说“颜色只使用输出到终端”? [英] What does git-config(1) mean when it says "colors are used only when the output is to a terminal"?

查看:241
本文介绍了git-config(1)是什么意思,当它说“颜色只使用输出到终端”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我输出到终端,但是Git没有正确地检测到我输出到终端,目的是为输出着色。我的问题是,git-config(1)是什么意思,当它说颜色只用于输出到终端时(这个短语出现在多个配置描述的结尾,如color.ui和颜色。科)?换句话说,Git如何决定是否输出到终端,以及如何更改我的环境设置以通知Git我的终端确实是终端?

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?

详细信息:

我在Windows上使用rxvt终端与Cygwin。我也安装了MSysGit。当我进行Git配置设置:

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

那么有正确的彩色输出。但是,我需要切换回自动,而不是总是,以便正确处理实际的非终端情况。所以为了使auto正常工作的目的:如何更改我的环境,使Git认识到我的rxvt + Cygwin是一个能够支持颜色的终端?

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。我不能使用Cygwin版本的Git,由于比这个相对较小的颜色问题更大的问题。请不要回复告诉我切换到Cygwin版本。)

(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.)

感谢您的帮助!

推荐答案

这可能值得看看这个问题,其涵盖检测到终端(即tty会话)的输出和它之间的差异被重定向到另一进程。我假设这是git在去终端的短语中意味着,输出实际上是一个tty会话。

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.

这篇关于git-config(1)是什么意思,当它说“颜色只使用输出到终端”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆