彩色输出与Cygwin命令在cmd [英] Colored Output with Cygwin Commands on cmd

查看:441
本文介绍了彩色输出与Cygwin命令在cmd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Windows XP SP3(不幸的是)

Operating system: Windows XP SP3 (Unfortunately)

我已经下载并安装了最新版本的Cygwin和Git。我也配置了我的环境包括每个在我的系统路径的bin文件夹,并设置一个用户变量TERM = msys。现在我可以进入cmd并使用以下命令,例如:

I have downloaded and installed the latest version of Cygwin and Git. I also have configured my environment to include the "bin" folders for each in my system path and also set a user variable TERM=msys. I can now go into cmd and use the following command, for example:


git status

git status

并获得彩色输出,即状态,要提交的更改为绿色,而未跟踪的文件等为红色。这不是没有设置TERM = msys的情况。

and get colored output, i.e. for status, changes to be committed are green, while untracked files and such are red. This was not the case without having set TERM=msys.

但是,由于我也添加了Cygwin bin到我的路径,我可以使用

However, since I also added the Cygwin bin to my path, I can use


ls

ls

获取目录列表, 。我是正确的假设,因为我只是通过cmd使用二进制文件,而不是Cygwin本身,得到彩色输出将不同于只是配置BASH配置文件不同?假设这是可能的;但是它似乎遵循如果它可以用Git完成,那么它也可以用Cygwin二进制文件。

to get a directory listing, but not with colored output. Am I correct in assuming that, since I'm only using the binaries through cmd, and not Cygwin itself, that getting colored output would have to be done differently from just configuring a BASH profile? Assuming this is possible; however it would seem to follow that if it can be done with Git, then it can also be done with the Cygwin binaries.

我很乐意阐述或澄清任何细节。谢谢。

I'd be happy to elaborate or clarify any details. Thanks.

推荐答案

当您执行 ls --color 。由于您无法在cmd.exe中使用别名,因此您可以使用 doskey Windows实用程序。

The basic colors should still work when you do ls --color. Since you can't use alias in cmd.exe, you can use the doskey windows utility.

doskey ls = ls --color

有多种方法可以让它使命令每次自动运行启动cmd.exe shell。以下是一个: http://www.tildemark.com/loading-doskey-automatically -with-cmd /

There are various ways you can make it so the command gets run automatically every time you start a cmd.exe shell. Here's one: http://www.tildemark.com/loading-doskey-automatically-with-cmd/

这篇关于彩色输出与Cygwin命令在cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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