bash Cygwin:git 的颜色编码和分支信息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11970658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:02:39  来源:igfitidea点击:

Cygwin: color coding and branch info for git?

gitbashcygwingit-bash

提问by Martin

Seem to be having a problem because I just recently changed my client for the gitbash to cygwin but i am missing color coding when i do git status for example and also the bash prompt doesn't include the current branch / rebase etc

似乎有问题,因为我最近刚刚将 gitbash 的客户端更改为 cygwin,但是当我执行 git status 时我缺少颜色编码,并且 bash 提示不包括当前分支/rebase 等

Does anyone know how to make cygwin look like gitbash? You maybe wondering why i changed, well i wanted more commands available :-)

有谁知道如何使 cygwin 看起来像 gitbash?你可能想知道我为什么改变,我想要更多可用的命令:-)

surley this must be supported

surley 这个必须支持

Any ideas?

有任何想法吗?

Thanks in advance

提前致谢

回答by Lee Netherton

It sounds like you just need to set up your .gitconfigfor your cygwin shell to enable coloured output. Here is what I have in my ~/.gitconfigfile (with which I get coloured markup in the output):

听起来您只需要.gitconfig为 cygwin shell 设置即可启用彩色输出。这是我的~/.gitconfig文件中的内容(我在输出中使用彩色标记):

[color]
        diff = auto
        status = auto
        branch = auto
        interactive = auto
        ui = true
        pager = true

I think the most important line here is ui = true, which you can turn on straight from the command line if you wish:

我认为这里最重要的一行是ui = true,如果您愿意,可以直接从命令行打开它:

git config --global color.ui true

回答by JJS

Answer by @lee-netherton is correct.

@lee-netherton 的回答是正确的。

For those using Windows Git-1.8.1.2-preview20130201 - I had to create a ~/.bashrc to enable color output from git status.

对于那些使用 Windows Git-1.8.1.2-preview20130201 的人 - 我必须创建一个 ~/.bashrc 来启用来自 git status 的颜色输出。

[~/.bashrc]

[~/.bashrc]

TERM=cygwin
export TERM