简体   繁体   中英

Why do I get all kinds of crazy characters in my emacs shell?

When I open a shell in emacs (Mx shell) it has trouble displaying many "normal" characters. I'm using Putty on Windows to connect to a linux server (a bash shell). I'm running emacs within Putty with "emacs -nw".

What causes this and how can I fix it?

For example,

Without emacs:

username@server:~/so$ ls -a
.  ..  bar.txt  foo.txt
username@server:~/so$

In emacs:

username@server:~/so$ ls -a
^[[0m^[[01;34m.^[[0m  ^[[01;34m..^[[0m  bar.txt  foo.txt
^[[musername@server:~/so$

What you're seeing are ANSI control sequences for colouring output.

Emacs actually has a number of different ways to access a shell . They each have strengths and weaknesses.

Instead of Mx shell , try Mx ansi-term . This supports ANSI colours out of the box and is likely the closest to a "regular terminal", eg PuTTY, Konsole or Gnome Terminal.

Try this:

(add-hook 'comint-output-filter-functions 'ansi-color-process-output)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM