Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

marked as duplicate by terdon, Anthon, Evan Teitelman, 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.

1 Answer

Use the emacs library ansi-color.el:

M-x load-library ansi-color
M-: (ansi-color-apply-on-region (point-min) (point-max))
share|improve this answer
add comment

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