emacs shell 命令输出不显示 ANSI 颜色,但显示代码
当我做M-!在我的 emacs 21.4 中,ANSI 代码是字面意思。例如:ls --color
^[[0m^[[0m05420273.pdf^[[0m
^[[0m100829_Baño1.pdf^[[0m
有没有办法让它具有颜色和UTF8?
同样的问题之前已经回答过< /a> 但结果并不完全令人满意(给出的解决方案是打开 shell 模式)。我知道如何在贝壳中添加颜色。我只想知道怎么才能和M有颜色! (shell 命令)或者如果根本不可能。
当您只想快速显示某些内容并且不想移动到此缓冲区并且希望它在没有 Cxk 的情况下自动消失时,shell 模式的干扰性太大。显然,在某些情况下,shell 缓冲区更方便,但由于另一个问题,我发现了如何将颜色添加到 shell 模式。
【注意】emacs使用中 builder6.centos.org 上的 2008 年 6 月 15 日的 GNU Emacs 21.4.1(x86_64-redhat-linux-gnu、X 工具包、Xaw3d 滚动条)
When I do M-! in my emacs 21.4 the ANSI codes gets literal. Eg: ls --color
^[[0m^[[0m05420273.pdf^[[0m
^[[0m100829_Baño1.pdf^[[0m
Is there a way of having it with color and UTF8?
The same question has been answered in SO before but with not totally satisfactory results (the solution given was to open a shell-mode). I know how to have colors in a shell. I only want to know how I can have color with M! (shell-command) or if it is not possible at all.
A shell mode is too intrusive when you want only to show something quick and don't want to move to this buffer and you would like to have it disappear automatically without C-x-k. Obviously there are situations where a shell buffer is more convenient but thanks to the other question I found how to put color to the shell-mode.
[note] emacs in use
GNU Emacs 21.4.1 (x86_64-redhat-linux-gnu, X toolkit, Xaw3d scroll bars) of 2008-06-15 on builder6.centos.org
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ansi-color.el
包含处理 ANSI 颜色代码的函数。不幸的是,并没有真正的好方法将其挂接到shell-command
中。这是一个 hack,但它有效:ansi-color.el
contains the functions to process ANSI color codes. Unfortunately, there's not really a good way to hook it intoshell-command
. This is something of a hack, but it works:关于 UTF-8:
这是来自
shell-command
的文档。About UTF-8:
This is from the documentation of
shell-command
.