1

So I'm running an Arch Linux installation with PowerLevel10k on OhMyZsh. I have the SynthWave84 theme on Visual Studio Code, and in the Integrated Terminal I get a weird % sign after the program's output. Everything's set to build based off of a tutorial that I've found, and everything was fine until I switched to Oh My Zsh. Here's a screenshot of the issue:

as you can see, there's a % after program output. So how do I fix it?

thrig
  • 34,938

1 Answers1

1

This is the way that ZSH indicates that a program did not include a newline to end the ultimate line of output:

% PS1="someothershellprompt "
someothershellprompt printf "hello world"
hello world%
someothershellprompt PS1='%# '
% 

The fix is to ensure that programs emit lines with ultimate newlines so probably in your case to use "Hello World!\n" or some other means of including the ultimate newline.

Without the ultimate newline you can get silent data loss in bad code such as

% printf "one\ntwo" | while read line; do echo $line; done
one
% 

so it's probably best to always include that ultimate newline (pretty sure POSIX demands it be there for a file to be a text file).

(Note that there are a lot of flaws in the above while loop. If you are actually planning on doing programming in a shell, especially a POSIX shell (which ZSH is not, by default), the flaws really should be corrected;

printf "one\ntwo\n" |\
while IFS= read -r line || [ -n "$line" ]; do printf '%s\n' "$line"; done

or, you could switch to a programming language that has less problematic (and doubtless much faster) line handling capabilities.)

thrig
  • 34,938