如何在(emacs)shell命令的输出中有颜色? [英] How to have colors in the output of (emacs) shell-command?

查看:132
本文介绍了如何在(emacs)shell命令的输出中有颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当执行命令 shell-command 时,相关缓冲区中显示的输出不会被着色。



调用时特别烦人一个测试框架(输出黄色/绿色/红色...)从emacs。



我如何配置或扩展emacs以使 shell -command 允许在shell中进行彩色输出并保留颜色,同时代表该输出?



谢谢!



PS。我正在使用Bash shell,在UN * X系统上。

解决方案

您可以实现自己的shell-execute,像



<$
(shell(get-buffer-createmy-shell-buf)($)

(process-send-string(get-buffer-processmy-shell-buf)(concat cmd\\\
))
/ pre>

When executing the command shell-command, the output shown in the associated buffer is not colorized.

This is particularly annoying when calling a testing framework (outputting yellow/green/red...) from within emacs.

How can I configure, or extend, emacs in order to have shell-command allowing colorized output in the shell and preserving the colors while representing that output?

Thanks!

ps. I'm using the Bash shell, on a UN*X system.

解决方案

You can implement your own shell-execute, something like

(defun my-shell-execute(cmd)
   (interactive "sShell command: ")
   (shell (get-buffer-create "my-shell-buf"))
   (process-send-string (get-buffer-process "my-shell-buf") (concat cmd "\n")))

这篇关于如何在(emacs)shell命令的输出中有颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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