efaq: Escape sequences in shell output
5.48 Why these strange escape sequences from ‘ls’ from the Shell mode?
======================================================================
In many systems, ‘ls’ is aliased to ‘ls --color’, which prints using
ANSI color escape sequences. Emacs version 21.1 and later includes the
‘ansi-color’ package, which lets Shell mode recognize these escape
sequences. In Emacs 23.2 and later, the package is enabled by default;
in earlier versions you can enable it by typing ‘M-x
ansi-color-for-comint-mode’ in the Shell buffer, or by adding ‘(add-hook
'shell-mode-hook 'ansi-color-for-comint-mode-on)’ to your init file.