July 27, 2005

Fixing Garbage Characters in the Emacs Shell

In a recent entry, I mentioned that loading the default .bashrc file in Debian turns on terminal coloring. Unfortunately, if you ever use the the shell buffer in Emacs, this has the unfortunately concequence of outputting garbage characters any time you try to run ls:

wjstaige@joshstaiger:~$ ls ^[[0m^[[01;32m#.bash_profile#^[[0m ^[[01;34mMail^[[0m ^[[01;34mblosxom^[[0m ^[[01;34mdownloads^[[0m ^[[01;34mwebadmin^[[0m ^[[mwjstaige@joshstaiger:~$

The solution is to add the following to your .emacs file:

;;; Fix junk characters in shell mode
(add-hook 'shell-mode-hook
         'ansi-color-for-comint-mode-on)

In Technology and Software

Posted by Josh Staiger at 07:29 PM