如何在 WinXP cmd shell 中加载 ANSI 转义码或获取彩色文件列表?

发布于 2024-07-23 21:57:51 字数 782 浏览 9 评论 0原文

这与此 问题:如何获取 Windows cmd shell 中的彩色文件列表?

我正在尝试获取 Windows cmd shell 中的彩色文件列表,你相信吗? Windows 是 XP SP2,如果这很重要的话。
在旧的 DOS 时代,曾经有一些小程序,如 hdir、adir 等,它们显示得很好。 如今,此类计划已不复存在。

然而,有来自 unixkit-tiny 或 unixtools 的ls。 不幸的是,它使用 ANSI 转义码来显示颜色,而 cmd 不能很好地处理这些代码。

有几种解决方案,包括加载 ansi.sys 和 command.com,但 command.com 不能很好地处理长文件名,而且速度非常慢。 即使如此,有时显示颜色也会出现问题。

所以我要问的是,除了使用 cygwin 之外,还有没有办法在 Windows cmd shell 中获取彩色文件列表? 或者有没有办法让 ANSI 转义码与 cmd.exe 一起工作,以便本机 ls 能够很好地发挥作用?

This is related to this question : How to get coloured file listing in windows cmd shell ?

I'm trying to get, wouldn't you believe it, coloured file listing in windows cmd shell. Windows are XP SP2, if that matters.
In the old DOS days there used to be little programs like hdir, adir and such which displayed that nice. Nowadays, such programs are no more.

There is however, ls, from unixkit-tiny or unixtools. Unfortunatelly, it uses ANSI escape codes for displaying colours, and cmd doesn't handle those too well.

There are several solutions which include loading ansi.sys and command.com, but command.com doesn't handle long filenames that well, and is awfully slow. Even then sometimes it has problems displaying colours.

So what I'm asking, is there a way to get coloured file listing in windows cmd shell, apart from using cygwin ? Or is there a way to get ANSI escape codes to work with cmd.exe in a way so that native ls will play nicely ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

原谅过去的我 2024-07-30 21:57:51

我在 http://adoxa.110mb.com/ansicon/index.html 遇到了 ANSICON ansicon github repo

使用它对 NAnt 输出进行着色。 ls --color 正在正确处理。

提供了源代码,但我没有检查过。

I ran across ANSICON at http://adoxa.110mb.com/ansicon/index.html ansicon github repo

Using it to colorize NAnt output. ls --color is being processed correctly.

Source code is provided, but I haven't examined it.

久夏青 2024-07-30 21:57:51

实际上,我认为 ansicon 的 A+ - 使用

  • ansicon.exe -I

将其安装为 CMD.exe 会话上的过滤器。 与 HTTY(红宝石)一起享用。

:-)

Actually I reckon A+ for ansicon -- Use

  • ansicon.exe -I

Installs it as a filter on your CMD.exe sessions. Works a treat with HTTY (ruby gem).

:-)

故乡的云 2024-07-30 21:57:51

您可以启动内置 Telnet 服务器,将其设置为仅允许 localhost 访问的防火墙,并使用能够理解此类转义的 telnet 客户端(甚至是本机客户端)。 (我知道,这是一个丑陋的黑客。)

You could start the builtin Telnet server, firewall it to only allow localhost access, and use a telnet client that understands such escapes - even the native one. (I know, an ugly hack.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文