6

No matter I use term or ansi-term to start zsh in Emacs, I encounter this problem, whenever I input commands, the output will have some junk characters like:

[ruby-1.9.2] ~ pwd
2;pwd1;pwd/Users/tyraeltong

the 2;pwd1;pwd is screwing the output, don't know whether others are experiencing same problem? I found a similar thread here Getting Emacs ansi-term and Zsh to play nicely but by [[ $TERM == eterm-color ]] && export TERM=xterm I still see the junk characters.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Tyrael Tong
  • 751
  • 10
  • 21
  • It's a problem caused directly or indirectly by something in your `.zshrc`. Probably a bad prompt setting, or one that makes unwarranted assumptions about the terminal it's running in. Post your `.zshrc`. – Gilles 'SO- stop being evil' Sep 21 '11 at 22:57
  • 2
    Actually I didn't make any customization in my .zshrc, instead, I just using .oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh – Tyrael Tong Sep 25 '11 at 13:49

3 Answers3

6

Emacs doesn't play nice with ZLE, so I have this in my ~/.zshrc:

if [[ -n ${INSIDE_EMACS} ]]; then
    # This shell runs inside an Emacs *shell*/*term* buffer.
    prompt walters
    unsetopt zle
fi
Tassilo Horn
  • 791
  • 8
  • 14
  • Thanks for reply, but with this setting, I still see the extra bits, e.g: 2;LS -G -lhF1;lstotal 72 – Tyrael Tong Mar 07 '12 at 01:22
  • Hm, is INSIDE_EMACS set? E.g., do `M-x shell` in emacs, and `echo $INSIDE_EMACS` in there. It should output something like "24.0.97.1,comint". If not, then that variable isn't set by emacs (maybe because your emacs is too old?!). In that case, you could change the test to `[[ ${TERM} == "dumb" ]]` which should also work. – Tassilo Horn Jun 08 '12 at 07:33
  • Ah, and you might also need this in your ~/.emacs: `(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)` – Tassilo Horn Jun 08 '12 at 07:37
  • humm, echo $INSIDE_EMACS will output something like "]2;echo 24.0.92.1,comint]1;echo24.0.92.1,comint". I also added the (add-hook) into the .emacs file, still see extra bits... BTW, which way are you using zsh under Emacs? is it "term", or "shell"? – Tyrael Tong Jun 10 '12 at 14:09
  • I use `M-x shell` and the `add-hook` above only works for that. After doing `M-x shell`, a `ls --color` should list files in colored. If you still get the raw color escape sequences, there's something wrong. – Tassilo Horn Jul 09 '12 at 13:48
3

Found the solution in the related post mentioned earlier

In a nutshell, in emacs M-x package-install and install multi-term. M-x multi-term kicks off a shell, with all the bells & whistles oh-my-zsh has to offer

Community
  • 1
  • 1
BitPusher
  • 990
  • 1
  • 9
  • 20
0

It could be an erronious PROMPT_COMMAND that has bash syntax. Try:

export PROMPT_COMMAND=""

and see if that helps.

Burton Samograd
  • 3,652
  • 19
  • 21