Why is a percent sign appearing before each prompt on zsh in Windows?

Solution 1:

The relevant option probably is PROMPT_SP, explanaition from the manual

Attempt to preserve a partial line (i.e. a line that did not end with a newline) that would otherwise be covered up by the command prompt due to the PROMPT_CR option. This works by outputting some cursor-control characters, including a series of spaces, that should make the terminal wrap to the next line when a partial line is present (note that this is only successful if your terminal has automatic margins, which is typical).

When a partial line is preserved, by default you will see an inverse+bold character at the end of the partial line: a % for a normal user or a # for root. If set, the shell parameter PROMPT_EOL_MARK can be used to customize how the end of partial lines are shown.

So, either you do a

unsetopt PROMPT_SP

if you don't care about the covered up line (however in your case it seems to be a empty line, as you get the % sign at the beginning).

Or use

setopt PROMPT_CR
setopt PROMPT_SP
export PROMPT_EOL_MARK=""

which preserves partial lines, but removes the % -- at the cost of some empty lines over the prompt.

To make this permanent, update your ~/.zshrc.

This is a blind shot, as I cannot reproduce this behaviour in my cmd.exe.

Solution 2:

So I was having the exact same issue with my zsh + oh-my-zsh.

I have fixed it with the help from mpy and those lines :

setopt PROMPT_CR

setopt PROMPT_SP

export PROMPT_EOL_MARK=""

You just have to go to -> ~/.oh-my-zsh/themes/XXXXXX You need to open the theme that you are using on oh-my-zsh so for me for exemple its agnoster.

Just open this file and copy / past those 3 lines at the end of the file.

And its fixed !!

Hope you have a nice day and that this will help some people out.

PEACE