Next: , Previous: Filling paragraphs with a single space, Up: Common requests

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.

In Emacs versions before 21.1, the ansi-color package is not included. In that case, you need to unalias ls for interactive shells running in Emacs; this can be done by checking the EMACS variable in the environment.