20

I'm getting zsh set up in Windows and I'm getting a reverse (black on white (black terminal background)) percent symbol in the first character position in the line just above every prompt.

Usually that means there's no newline at the end of the file, for example when cat-ing a file.

It doesn't happen on my Mac or even on Mintty on Windows. But it does happen in ConEmu and the standard terminal app that CMD.EXE usually runs in.

I've already unset all my prompt strings as well as precmd() which I normally use to add a blank line above the prompt.

Any clue what it could be?

4 Answers 4

39

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.

3
  • 1
    Thanks @mpy, this put me onto just the right spot to learn more. Here's what I came up with: 1) three things work, more if you combine options: unsetopt PROMPT_CR; unsetopt PROMPT_SP; and PROMPT_EOL_MARK="". 2) setting PROMPT_EOL_MARK="" gets rid of the annoying inverse+bold "%" character, but it still adds an additional line feed, so prompt looks different than on mintty or the Mac. 3) I ended up going with unsetopt PROMPT_SP as the best compromise. 4) using set and unset doesn't work unless you use the -o option. setopt and unsetopt work. If you'll fix I'll accept your answer :)
    – scanny
    Sep 15, 2013 at 22:04
  • 1
    @scanny : I have to apologize for the set. Of course, it should've been setopt -- obviously I wrote my answer too fast. I updated my answer and tried to include also the point about the empty lines.
    – mpy
    Sep 16, 2013 at 11:00
  • DO NOT unsetopt PROMPT_SP, see github.com/vercel/hyper/issues/3586#issuecomment-732747948
    – xuxu
    Jan 21 at 14:55
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

1
  • Please don't add "thanks" as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, which is the Super User way of saying thank you.
    – DavidPostill
    Sep 29, 2016 at 11:07
0

You can run mintty inside of ConEmu. That got rid of the percents for me.

Here's what I have for task parameters:

/icon "%ConEmuDrive%\msys64\msys2.ico"

and commands:

set CHERE_INVOKING=1 & %ConEmuDrive%\\msys64\usr\bin\mintty.exe -i "%ConEmuDrive%\msys64\msys2.ico" -
0

If you are using zsh shell , run the below lines in the terminal: echo 'setopt PROMPT_CR' >.zshrc echo 'setopt PROMPT_SP' >.zshrc echo 'export PROMPT_EOL_MARK=""' >.zshrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .