ZSH – Why ZSH Ends a Line with a Highlighted Percent Symbol

bashnewlinespromptzsh

I've noticed this on occasion with a variety of applications. I've often thought it was because the output was cancelled early (ctrl+c, for example) or something similar, and zsh is filling in a new line character. But now curiosity has gotten the best of me, since it doesn't seem to do this in bash.

zsh

zsh

bash

enter image description here

The Sequence program is something I pulled from a book while reading on Java certifications and just wanted to see if it would compile and run. I did notice that it does not use the println() method from the System.out package/class. Instead it uses plain old print().

Is the lack of a new line character the reason I get this symbol?

Best Answer

Yes, this happens because it is a "partial line". And by default zsh goes to the next line to avoid covering it with the prompt.

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.

Related Question