0

I've been using Emacs's ansi-term for a while, and it's usually worked, more or less. Recently, though, ansi-term has started interpreting the characters on the right side of my terminal as part of the commands I type. Here is the code for my prompt (using oh-my-zsh):

PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}$(get_pwd) %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} %{$reset_color%}'

function get_pwd() {
  print -D $PWD
}

return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"

RPROMPT='${return_code} %{$fg_bold[cyan]%}$(rvm-prompt)%{$reset_color%}$(git_prompt_status)%{$reset_color%}'


ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
#GIT_PS1_SHOWUPSTREAM=verbose

ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"

This is what it looks like:

➜  ~/.emacs.d git:(master)                                     ruby-2.1.0 ✖ ✹ ✭

And this is what ansi-term does:

➜  ~/.emacs.d git:(master) ✗ ls                                                                                    2 ↵ ruby-2.1.0 ✖ ✹ ✭
ls: cannot access 2: No such file or directory
ls: cannot access ↵: No such file or directory
ls: cannot access ruby-2.1.0: No such file or directory
ls: cannot access ✖: No such file or directory
ls: cannot access ✹: No such file or directory
ls: cannot access ✭: No such file or directory

I'm not sure what happened that would have triggered this problem, though I did upgrade all my packages recently. Is there a workaround?

Patrick Brinich-Langlois
  • 1,381
  • 1
  • 15
  • 29
  • Can you show your prompt ? – lmedinas Mar 17 '14 at 22:57
  • 1
    Does it happen with `emacs -Q` ? If not, then presumably those package updates broke it, so you should either revert the changes and then re-apply them one by one (or in binary-search fashion) to find the culprit (if you can't make an educated guess), or do the same in reverse -- revert the updates until it starts working (but reverting all the updates first will enable you to verify whether it definitely worked in that state). And if you don't have your config backed up or under version control, then I recommend that you start doing so immediately. – phils Mar 18 '14 at 00:05
  • Thanks for the advice. `emacs -Q` seems to fix the problem of the terminal interpreting the prompt as part of commands, but it still isn't usable: the output of commands isn't displayed. When I type a command and hit enter, the prompt flashes, but then everything looks exactly the same as it was before the command was run. – Patrick Brinich-Langlois Mar 18 '14 at 01:01
  • It may be a problem with oh-my-zsh. When I use the default theme, everything seems to work (even without `emacs -Q`). – Patrick Brinich-Langlois Mar 18 '14 at 01:03
  • 1
    @PatrickBrinich-Langlois looks like you using ansi-term in `line-mode`, just look at modeline does it have something like `Term: line`? BTW the custom prompt works for me –  Mar 18 '14 at 01:28
  • The problem seems to be partly due to my custom prompt and partly due to my Emacs config. Here's a summary: In Gnome Terminal, all the oh-my-zsh themes I've tried, and my custom theme, work. With `emacs -Q`, all the themes included with oh-my-zsh, but not my custom theme, work. With `emacs`, themes with prompts that have stuff on the right don't work, but ones that don't have stuff on the right *do* seem to work. Maybe I'll just go with a simpler prompt. – Patrick Brinich-Langlois Mar 18 '14 at 02:40
  • @PatrickBrinich-Langlois did you check the mode `ansi-term` is running in? Try switching to 'char-mode` by hitting `C-c C-k`, the custom prompt you provided in the question worked for me. –  Mar 18 '14 at 16:23

0 Answers0