I use multi-term within spacemacs for most of my command-line operations. It works well except some annoying behavior in the shell prompt (zsh but similar for bash) on commands which go over the screen width.
I tried many things without success to fix it but I discovered that if I run the same shell within neovim within multi-term the prompt has no problem. Of course that is not ideal as I cannot scroll up but it may help to isolate the issue.
See below the behavior (I type "l" repeatedly then backspace):
Spacemacs (0.200.13@26.1, Ubuntu 16.04, same issue with 25.3) configuration related to the terminal
(setq multi-term-switch-after-close nil)
(setq term-suppress-hard-newline t)
(setq term-char-mode-point-at-process-mark nil)
(add-hook 'term-mode-hook '(lambda () (toggle-truncate-lines 1)))
The issue appears regardless of the value of toggle-truncate-lines.
Any idea of what could cause this behavior?
EDIT:
I debugged with (setq term-log-buffer t)
and the syntax highlighting in zsh makes things even more complex.
Disabling it, the cursor simply returns to the beginning of the line instead of one line below:
It seems that when the line reaches the screen width, the shell sends ^M^[[K
, a carriage return and a line kill, so emacs
does as expected.
Not sure why the shell does not return a line feed too.
With bash --norc
, the shell sends only ^M
at the end of the line so emacs
keeps overwriting the same line without erasing it like for zsh
.
EDIT2:
Learning more about terminals, the shell behavior seems to be standard.
The issue is then that emacs
doesn't properly handle the SPCR sequence in this case.
EDIT3: Reported as a bug.