I have sent a bug report to the zsh maintainers, but it seems this behavior is by design. This issue however annoyed me so much that I decided to patch and compile zsh myself as a temporary fix. If you're on OS X and use Homebrew (you should), then you can install zsh including my patch by running:
brew install https://gist.github.com/padde/7963205/raw/eaedcc557859a40db87282fc39256fccd52d0aad/zsh.rb
you will likely want to add /usr/local/bin/zsh
to /etc/shells
and chsh -s /usr/local/bin/zsh
afterwards. Lastly, here's the raw diff for anyone who's interested:
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 17b78ce..f136178 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1576,7 +1576,7 @@ zrefresh(void)
else
put_rpmpt = rprompth == 1 && rpromptbuf[0] &&
!strchr(rpromptbuf, '\t') &&
- (int)ZR_strlen(nbuf[0]) + rpromptw < winw - 1;
+ (int)ZR_strlen(nbuf[0]) + rpromptw < winw;
} else {
/* insert >.... on first line if there is more text before start of screen */
ZR_memset(nbuf[0], zr_sp, lpromptw);
@@ -1631,9 +1631,9 @@ zrefresh(void)
if (put_rpmpt && !iln && !oput_rpmpt) {
int attrchange;
- moveto(0, winw - 1 - rpromptw);
+ moveto(0, winw - rpromptw);
zputs(rpromptbuf, shout);
- vcs = winw - 1;
+ vcs = winw;
/* reset character attributes to that set by the main prompt */
txtchange = pmpt_attr;
/*
5This also seems to place the input cursor one character to the left of where it would normally be. Using the prompts in this question, for example, the cursor is placed on the hash mark, rather than immediately to its right. (For me, setting the offset to a value less than zero makes the prompts and cursor appear in the correct places. Observed with zsh 5.0.8 and 5.2.) – Rob Kennedy – 2016-04-22T19:49:29.543
Works for me in 5.2. – Anthony Michael Cook – 2016-04-23T00:10:26.900
5It kinda worked for me in 5.2, but now I have issues with PROMPT: last character in PROMPT disappeared and toggling autocompletion fills that last character with first character of current input. For example
%git<Tab>
transforms to%ggit
– roboslone – 2016-07-16T03:43:39.457You don't need to use the tricks for newer versions of ZSH. – Anthony Michael Cook – 2016-07-19T01:20:48.227
FWIW
ZLE_RPROMPT_INDENT=0
works fine for me in zsh 5.2, but only in some terminal emulators. For example vte3 fails, as per @roboslone's comment. I've testedterminator-gtk3-bzr
andgnome-terminal
in Arch Linux. – Sparhawk – 2016-10-18T05:22:48.6405
After setting ZLE_RPROMPT_INDENT=0 I noticed the same drawing glitch issues with the left-side prompt that some others mention above. However, almost everything works as expected if I use -1 instead of 0, i.e. ZLE_RPROMPT_INDENT=-1. I saw that tip at https://github.com/bhilburn/powerlevel9k/issues/110#issuecomment-395940663. Almost, because with -1 it never uses the bottom line of a terminal window on macOS.
– Marc Liyanage – 2019-03-08T18:39:17.460