vote up 1 vote down star
1

While emacs shell mode when I run

ls

I get following

   [0m[01;32mmanage.py[0m     [01;34mtemplates[0m

these must be manage.py and templates. Why its like that and how can fix it?

flag

2 Answers

vote up 4 vote down

Those are vt100 codes for color display (which is usually enabled by default on most Linux distros today). Emacs shell doesn't handle the vt100 escape codes.

Find out whether your ls command is aliased.

which ls

Does it look like like the following or something similar?

ls: alias to ls --color=tty

If so you'll need to find where this alias is set and unalias it or change how it is called.

Your shell knows it is running in an emacs shell if the EMACS environment setting is set to t. You can do something like the following to set alternate functions. I use zsh, so this contains some items specific to that shell.

## for emacs
if [[ $EMACS = "t" ]] then
   PROMPT="%# "  # make the prompt simple
   unsetopt zle  # turn off advanced line editting

   ls_pager=( cat ) # ls is simple piped to cat
   ls_flags=( -A )  # default ls flags
fi

For bash you can you just alias ls

alias ls='ls -A'
link|flag
+1 (Beat me, I was just typing in the same) But not as detailed... – Nifle Dec 16 at 19:42
which ls /bin/ls I use bash and putting alias ls='ls -A' did not worked – Gok Demir Dec 16 at 20:24
vote up 0 vote down

I put ~/.emacs

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

and it solved my problem. Anyway thanks for answering. The link that solved my problem.

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.