How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?

被刻印的时光 ゝ 提交于 2019-12-18 02:46:28

问题


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 ?


回答1:


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.




回答2:


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




回答3:


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

:-)




回答4:


It's possible to patch cmd.exe....

http://gynvael.coldwind.pl/?id=130&lang=en



来源:https://stackoverflow.com/questions/946546/how-to-load-ansi-escape-codes-or-get-coloured-file-listing-in-winxp-cmd-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!