-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
percent (%) character displayed before prompt when zsh is used #778
Comments
Thanks for this great report! As we've previously discussed on IRC, this is a valid bug report even the reporter is using some very old qterminal as I'm able to reproduce the issue on Arch Linux with the latest git-master.
That is a useful information. I moved away from oh-my-zsh some time ago. It might be the reason that I seldom see such an issue recently. |
Go inside the .zshrc file at the top you'll find:
That's what worked for me |
@xZliman I tried adding your quoted line¹ (uncommented) to the very top of my ¹ I did not have the comment in mine, because my file was based on an older template apparently. |
@M4he |
This worked great for me and I tried all other solutions! This was the only solution that provided results. |
I can reproduce this solution. Thanks! |
Hey everyone. I'm the developer of powerlevel10k. @flaviocamilo has tagged me on romkatv/powerlevel10k#1445. When you see the inverted percent before the first prompt upon opening a new terminal, this is almost always caused by a bug in the terminal or the window manager (wm). You can diagnose the nature of the bug with the following steps. First, add this snippet at the very top of PS1='%~ '
RPS1='%n@%m'
return This sets left and right prompt to very simple values and returns before evaluating anything else in your zsh config. If you can reproduce the problem with this The next step is to figure out which of the two common terminal/wm bugs is the culprit. The most common variety is that the TTY reports its size incorrectly for a short while after being created. To see whether this is the case add the following snippet at the very top of print -r -- "$COLUMNS x $LINES"
sleep 1
print -r -- "$COLUMNS x $LINES" When you open a new terminal, you should see the same dimensions printed twice and they should match the real dimensions of your terminal window. If you see different numbers reported on the first and the second line, or if they don't match the real dimensions of the terminal window, this is an indication of the bug I was referring to earlier. If you always see correct dimensions printed twice, check for another terminal/wm bug that can cause the inverted percent sign. This bug involves incorrect line wrapping during a short duration after the TTY is created. To check for it, add the following snippet at the very top of () {
emulate -L zsh -o prompt_percent
local -i n='COLUMNS - 1'
print -Prn -- X${(pl.$n.. .)}$'\r%E'
} When you open a new terminal, you should NOT see "X" at the top of your terminal window. If you do see it, that's a bug in the terminal/wm. Now, why do you see the inverted percent sign when using powerlevel10k instant prompt but not when using other themes? This is simply because other themes are unable to display prompt fast enough. Powerlevel10k displays prompt very quickly after you open a terminal window, so it can be affected by a terminal/wm bug that only manifests itself for a short duration after a TTY is created.
By redirecting the output to These are just workarounds though. Ideally the bug needs to be fixed in the terminal or the window manager. |
|
@gitzhangzhao Could you try it with the latest version of Powerlevel10k? I’ve implemented a partial workaround that might get rid of the inverted percent sign even without the |
@romkatv It worked, thank you very much! |
@gitzhangzhao Thanks for verifying! It's really just a workaround though. As I mentioned earlier, this is a bug either in the terminal or in the window manager. The bug is not specific to powerlevel10k and can easily be reproduced with a tiny zsh config. It's not specific to zsh either, which can be demonstrated by instructing the terminal to launch |
Expected Behavior
konsole
,gnome-terminal
,tilix
etc.)zsh
and oh-my-zsh configurations properlyCurrent Behavior
zsh
set as the default shell, a color-inverted percent sign (%
) will displayed above the promptzsh
andprompt adam1
set in~/.zshrc
zsh
as default shell and oh-my-zsh set upPossible Solution
I have found the following two end-user workarounds (not solutions) so far. Both with downsides. The permanent solution would be to fix whatever is causing this in qterminal directly.
Workaround 1
~/.zshrc
:Workaround 2
~/.zshrc
:%
disappear but an empty line will still be displayed above prompts in new qterminal instancesSteps to Reproduce (for bugs)
*-xfce.iso
from here). All following instructions refer to the live system..zshrc
in the current home directory (~/.zshrc
) with the following contents:user
, password islive
). The commandecho $SHELL
should now display/bin/zsh
.Context
The
zsh
shell is often used in conjunction with oh-my-zsh to provide convenient theming and extension management and configuration forzsh
. As of now, it doesn't seem possible to use suchzsh
configuration with qterminal without having buggy behavior of the prompt in new terminal instances (erroneous newlines or%
characters displayed above the prompt).It would be great if qterminal could be compatible with
zsh
configurations the same way that all other popular terminal emulators are.System Information
Notes and References
Notes:
prompt walters
in~/.zshrc
on the Debian setup without oh-my-zsh, the issue seems to disappearzsh
with the config above will only rarely make the issue appear; however, installing oh-my-zsh also seems to make it reproducible on UbuntuReferences:
zsh
and%
:PROMPT_SP
stuff in regards to the%
appearanceThe text was updated successfully, but these errors were encountered: