ZSH powerlevel10k shell bug when showing git branch name

I tried Manjaro LXQt and Manjaro KDE/PLASMA and found that the ZSH shell has a bug in showing the branch name when there are no changes in the repository

As per the attached image, when the repository is initialized, the branch name does not have the last character.
The complete branch name appear only when there are some changes in the repository.

InkedZshPowerlevel10kBug

Which font are you using?

I’m also facing this issue, I think It’s related to the font-width, because I haven’t faced this issue when changed font to Noto Sans / Open Sans.

I’m also searching for helps about how to fix or check for font-width related problems. I’m facing this this problem when I’m using Monospace, Droid Sans or Inconsolata fonts.

Hi,

I encountered this bug and was able to solve the issue.

modify and edit (sudo) p10k.zsh file

sudo nano /usr/share/zsh/p10k.zsh 

then find this lines of code in the file:

# If local branch name or tag is at most 32 characters long, show it in full.
# Otherwise show the first 12 … the last 12.
# Tip: To always show local branch name in full without truncation, delete the next line.
(( $#where > 32 )) && where[13,-13]="…"
res+="${clean}${where//\%/%%}"  # escape %

next is you add a little space at the end of the res variable.

res+="${clean}${where//\%/%%} "  # escape %

and voila!

image

Thank me later

3 Likes

Hi,
Adding to the point of @Catzilla .
You see, the question mark (or exclamation mark) is not the end of the git status either. There is a number following it indicating the number of modified files. In the end, where a space is lacking is not the branch name, but at the end of the entire line. And you just need one more space at the end of res.
So the better way is to add a space to res before it is printed:

   res+=" " <---add this 
   typeset -g my_git_format=$res
}
1 Like