怎么看在MSYS / Git的Bash的色彩输出的蚂蚁? [英] How to see color Ant output in MSYS/Git Bash?

查看:285
本文介绍了怎么看在MSYS / Git的Bash的色彩输出的蚂蚁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 AnsiColorLogger 从的Ant 。我使用混帐击在Windows 的。

I'd like to use AnsiColorLogger to get color ouput from Ant. I'm using Git Bash on Windows.

我试过:

$ ant -logger org.apache.tools.ant.listener.AnsiColorLogger

但我的输出如下:

but my output looks like:

Buildfile: c:\foo\build.xml
←[2;36m    [junit] Testsuite: org.foo.BarTest←[m
←[2;36m    [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.188 sec←[m
←[2;36m    [junit] ←[m
←[2;36m    [junit] Testcase: testInherits took 0.175 sec←[m
←[2;36m    [junit]      FAILED←[m
←[2;36m    [junit] subdir not child←[m
←[2;36m    [junit] junit.framework.AssertionFailedError: subdir not child←[m
←[2;36m    [junit]      at org.foo.BarTest.testInherits(BarTest.java:61)←[m
←[2;36m    [junit] ←[m
←[2;31m    [junit] Test org.foo.BarTest FAILED←[m

我知道ANSI颜色的工作,至少部分,在Git中的Bash因为像 LS -ACF --color =汽车命令产生漂亮的彩色输出。

I know ANSI colors work, at least partially, in Git Bash because commands like ls -ACF --color=auto produce nicely colored output.

什么是Ant的把戏?

推荐答案

多谷歌搜索和实验后,我结合一些变化成的混帐击,蚂蚁和Windows的特定组合行之有效的解决方案。

After much Googling and experimentation, I combined several variations into a solution that works well for the particular combination of Git Bash, Ant and Windows.

重新开张的Git猛砸添加以下行到你的的.bashrc 文件之后:

Relaunch Git Bash after adding the following lines to your .bashrc file:

alias ant='cant'
function cant {
  "ant" -logger org.apache.tools.ant.listener.AnsiColorLogger "$@" \
      2>&1 | perl -pe 's/(?<=\e\[)2;//g'
}

的Git Bash的菜鸟提示: 的.bashrc 文件,如果存在的话,住在你的home目录。以下是如何创建/编辑:

Git Bash Noob Tip: .bashrc file, if it exists, lives in your home directory. Here's how to create/edit it:

$ cd
$ notepad .bashrc &

这篇关于怎么看在MSYS / Git的Bash的色彩输出的蚂蚁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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