Pregunta

I M-x shell to run a program that tries to produce nice color output. But I get:

?- true.
^[[1mtrue.^[[0m

This is clearly not a fault of EMACS, as it sets the environment variable TERM to dumb. It is just the program I called that ignored this information.

I am aware of ansi-color-for-comint-mode-on which fixes this problem in an ad hoc manner: The environment variable TERM is still dumb. That is, a program interpreting this variable accordingly would not use escapes at all.

Is there a less ad-hoc approach to this, setting the TERM or similar?

¿Fue útil?

Solución 2

You can use M-x ansi-term instead of the other shells (M-x shell, M-x term and M-x eshell). Ansi-term was designed to work off-the-shelf with ansi colors. And even better, I suggest that you use multi-term (you can read more about it here and here) which essentially supports all the features of ansi-term plus the ability to easily switch between terminals and define which keyboard shortcuts are sent to the terminal and which ones are captured and interpreted by Emacs.

Otros consejos

If M-x ansi-color-for-comint-mode-on does it, customizing ansi-color-for-comint-mode should be all you need.

Maybe, in line with the examples below:

(setenv "DISPLAY" ":0")

(setenv "PATH" (concat "/home/an_user/bin:"
                (getenv "PATH")))

You could try:

(setenv "TERM" ....)

Or is this not what you had in mind?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top