This question already has an answer here:

I have some log files that have ansi-color codes in them. When I open them in Emacs I see garbage:

          enter image description here

As an example, I run the following:

ls --color=yes -ald -- * > my_files.txt

on a generic folder (using gnome-terminal in Ubuntu with zsh)

The interesting thing is that if I run

cat my_files.txt

the shell displays the contents correctly in color (i.e. the shell knows how to interpret those ansi-codes)

Is there any way to have Emacs display such files correctly as well?

marked as duplicate by terdon, Anthon, user26112, jasonwryan, slm Jul 17 '13 at 19:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use the emacs library ansi-color.el:

M-x load-library ansi-color
M-: (ansi-color-apply-on-region (point-min) (point-max))

Not the answer you're looking for? Browse other questions tagged or ask your own question.