Why does shell mode display some rubbish code?

588 views Asked by At

When I use bower in M-x shell, as you can see in the picture, some rubbish code is displayed.

Emacs shell mode

However M-x ansi-term works well

ansi-term

What could be the problem ? Is it possible to make shell mode display properly ?

3

There are 3 answers

1
Tim Pierce On

Those symbols are ANSI escape sequences that the terminal emulator uses for visual effects like changing the color of text. shell-mode apparently doesn't know how to display these codes by default. What you want may be Term Mode:

Some programs (such as Emacs itself) need to control the appearance of the terminal screen in detail. They do this by emitting special control codes. Term mode recognizes and handles ANSI-standard VT100-style escape sequences, which are accepted by most modern terminals, including xterm. (Hence, you can actually run Emacs inside an Emacs Term window.)

1
Ehvince On

Try the solution given in Cucumber's ANSI colors messing up emacs compilation buffer:

 (require 'ansi-color)
 (defun colorize-compilation-buffer ()
 (toggle-read-only)
 (ansi-color-apply-on-region (point-min) (point-max))
   (toggle-read-only))
 (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

that works beautifuly for me on emacs24.


ps: to colorize even more the shell output I like to play with

M-x highlight-regexp RET a regexp, i.e. \[OK\] RET a color (make use of TAB to see choices)

or

(add-hook 'shell-mode-hook (lambda () (highlight-regexp "\\[OK\\]" "hi-green-b")))

and (add-hook 'shell-mode-hook (lambda () (goto-address-mode ))) to make URLs clikable. Looking for the same stuff for file paths.

edit: making file paths clickable is as easy as using compilation-shell-minor-mode :)

edit2: my sources: http://wikemacs.org/index.php/Shell

0
Andreas Röhler On

WRT to bash, sometimes setting $PAGER helps here, i.e.

PAGER=cat