Reputation: 1447
When I run a shell command in Emacs, I often see what look like ANSI codes. They seem to happen when the shell process spawns a new process.
Here's an example from running Stata in an Emacs shell. The ANSI codes (if this is what they are) are visible at the bottom:
. ls *.tex
ls *.tex
-rw-r--r-- 1 pnj staff 78006 Jun 23 17:21 un_paper.tex
-rw-r--r-- 1 pnj staff 1821 Dec 22 2013 un_results.tex
. shell ls *.tex
shell ls *.tex
^[[?1l^[>un_paper.tex un_results.tex
^[[?1h^[=
.
Note: There are many similar SO questions about ANSI color escape sequences. This is not my problem! I already have required ansi-color
, and ansi-color-for-comint-mode-on
, and ANSI colors are working. Also, using ansi-term solves this problem, but I much much much prefer the buffer-like characteristics of the standard shell. eshell does slightly better but still displays some escape codes.
My guess is that these are screen mode / cursor movement codes, but I can't figure out how to get emacs to either ignore or process them. TERM is set to xterm-256color.
Update: I learned that the h and l codes are used for setting terminal/display mode, which I presume Emacs cannot process. Is there a way I can suppress them from being displayed?
Upvotes: 4
Views: 2381
Reputation: 54583
Actually, emacs supports colors in shell
, but only partially. There's a terminal description in ncurses (dumb-emacs-ansi
), with notes on why you wouldn't want to use it (the comments preceding the entry).
Upvotes: 0
Reputation: 2280
As you say, Emacs' eshell can't process escape codes -- it is a "dumb" terminal. But, your TERM variable setting is telling your shell that it IS capable of processing those escape codes.
Setting TERM to "dumb" when you're inside eshell should make those ugly escape codes go away.
Upvotes: 3