Prompt jumps up a line on certain actions
I think I've seen this with a few different actions but the one that I know is repeatable is when I type 'S' in command mode. The following sequence does it for me reliably.
- Either open a new terminal or just hit
to get a fresh prompt. - Type
<esc>S
At this time, the prompt jumps up deleting whatever line came before it. In my case, I use a two-line prompt, and both lines in the prompt jump up to delete the line of output before them.
To illustrate, I open up a new terminal and echo some output. At this point, my terminal looks like this:
Last login: Wed Sep 8 14:38:23 on ttys004
╭─ ~ ✔
╰─ echo "output to be clobbered by the next prompt"
output to be clobbered by the next prompt
╭─ ~ ✔
╰─
Then, I hit <esc>S and my terminal looks like this:
Last login: Wed Sep 8 14:38:23 on ttys004
╭─ ~ ✔
╰─ echo "output to be clobbered by the next prompt"
╭─ ~ ✔
╰─
Notice that the line of output following the echo got eaten and my prompt is now one line higher in the terminal than it started at.
This is something I run into all the time because I often start typing a command, realize that I needed to run something different first, and I hit <esc>S to start over. Occasionally, some output that was important is clobbered by this bug.
As I was playing with this and writing the initial description, I realized that if I hit <esc>S repeatedly, it will eat all of the lines in the terminal until the prompt gets to the top of the screen.
I think maybe this only happens with multi-line prompts. I'll try to narrow it down. I was able to reproduce it with the standard prompt fade.
A quick workaround is to disable the automatic tweaking of the prompt by setting MODE_INDICATOR= before you load zsh-vimi-mode:
MODE_INDICATOR=
source ~/path/to/zsh-vim-mode/zsh-vim-mode.plugin.zsh
I will see if I can find out what is causing this problem, but hopefully that workaround will help in the mean time.
This appears to be a Zsh bug. I narrowed it down to this minimal .zshrc:
autoload -Uz promptinit; promptinit
prompt redhat
PS1='%!
%# '
autoload -Uz add-zle-hook-widget
test-zle-reset-hook () { zle reset-prompt; }
add-zle-hook-widget line-pre-redraw test-zle-reset-hook
I was not able to get it to happen with a plain PS1 without first using prompt redhat (or any other promptinit prompt). I'm not yet sure if this is a bug in promptinit, zle's line-pre-redraw hook, or if I'm using something incorrectly.
The MODE_INDICATOR= work-around seems to be working just fine for me. I do not find the mode indicator useful and so I was not making use of it anyway. Thanks!