3 added 80 characters in body
source | link

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that the output has an unterminated line with a % character in bold and reverse video, and issues the next prompt at the beginning of the next line:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

unsetopt prompt_cr prompt_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that unterminated line with a % character in bold and reverse video:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

unsetopt prompt_cr prompt_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that the output has an unterminated line with a % character in bold and reverse video, and issues the next prompt at the beginning of the next line:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

unsetopt prompt_cr prompt_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

2 added 4 characters in body
source | link

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that unterminated line with a % character in bold and reverse video:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

set +ounsetopt promp_crprompt_cr promp_spprompt_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that unterminated line with a % character in bold and reverse video:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

set +o promp_cr promp_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that unterminated line with a % character in bold and reverse video:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

unsetopt prompt_cr prompt_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.

1
source | link

That's a specific feature of zsh (and now fish as well) to let you clearly see unterminated lines in a command's output.

In traditional shells, if a command outputs some data after the last newline character, or, in other words, if it leaves the terminal cursor not at the start of the line, the next prompt by the shell ends up appended to that last unterminated line as in:

bash-4.4$ printf XXX
XXXbash-4.4$

That mangles the prompt, and it's easy to miss that XXX there especially if you've got a fancier prompt like that. It also affects cursor positioning which causes display glitches when you move the cursor around.

zsh works around that, by showing that unterminated line with a % character in bold and reverse video:

zsh-5.1.1$ printf XXX
XXX%
zsh-5.1.1$

It does that by outputting that reverse video % at the end of every command (before each prompt), but followed by 79 spaces (assuming a 80 character wide terminal), a CR character (the one that causes the cursor to go back to the first column) and the sequence to erase to the end of the line (and then the prompt).

That way, if there was an unterminated line, since the cursor is not in first position, those 80 characters will make the cursor move to the next line (and that % will stay). If not, then that % and those 79 spaces will be on a one line which will be deleted afterwards.

Now, that only works if the terminal does wrap lines (for instance, that won't work properly after tput rmam). If you have a slow terminal (like on 9600 baud serial line), you may actually see those % being displayed and then removed after each command, so zsh lets you disable that feature:

set +o promp_cr promp_sp

That way, zsh behaves more like traditional shells.

You can also change that mark with the $PROMPT_EOL_MARK variable.