zsh in Emacs output junk characters
Asked Answered
M

3

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.

Maghutte answered 21/9, 2011 at 4:2 Comment(2)
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.Bedfast
Actually I didn't make any customization in my .zshrc, instead, I just using .oh-my-zsh: github.com/robbyrussell/oh-my-zshMaghutte
C
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
Cutback answered 5/3, 2012 at 7:1 Comment(5)
Thanks for reply, but with this setting, I still see the extra bits, e.g: 2;LS -G -lhF1;lstotal 72Maghutte
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.Cutback
Ah, and you might also need this in your ~/.emacs: (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)Cutback
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"?Maghutte
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.Cutback
B
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

Backman answered 12/10, 2013 at 22:16 Comment(0)
I
0

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

export PROMPT_COMMAND=""

and see if that helps.

Idelson answered 21/9, 2011 at 18:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.