Reputation: 4655
I use Ubuntu8.10 and emacs-snapshot. Running shell-mode on emacs and input "ls" shows escape codes:
screenshot http://lh3.ggpht.com/_os_zrveP8Ns/SdMmohKNjmI/AAAAAAAADB4/VlKpr5H_7ZA/s512/screen.png
How can I get the output I expect?
Upvotes: 31
Views: 10076
Reputation: 6878
I wrapped my alias ls ='ls --color=auto'
in ~/.bashrc:
case "$TERM" in
xterm*|rxvt*)
if [ -x /usr/bin/dircolors ]; then
alias ls='ls --color=auto'
...
fi
;;
*)
;;
esac
This disables using color=auto
in emacs.
Upvotes: 1
Reputation: 74430
Expanding on vatine's answer, you can add that inside your .cshrc (.tcshrc/.bashrc) wrapped with a check for the environment variable INSIDE_EMACS.
For example (from my .tcshrc):
if ( $?INSIDE_EMACS ) then
alias l 'ls --color=never'
endif
Upvotes: 3
Reputation: 3816
You can use AnsiTerm which does support colors or you can enable AnsiColor for the normal shell:
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
Upvotes: 44
Reputation: 26312
Furthermore, you may choose another shell: M-x term
or M-x eshell
. The former provides an interface that is much closer to a real terminal emulator than shell-mode
(once you start it, you can get out of the mode with C-c C-j
and get in again with C-c C-k
). The latter is a shell implementation written in Elisp (you can use the common shell commands as well as evaluating Lisp code).
Upvotes: 5
Reputation: 21258
The problem is that "l" is trying to colorise the output and emacs isn't having any of it. Try the following:
$ unalias l $ alias l ls --color=never
Upvotes: 1