Ohmyzsh: Wedisagree theme and git weird behaviour

Created on 4 Feb 2016  ·  3Comments  ·  Source: ohmyzsh/ohmyzsh

The wedisagree theme has a weird behaviour on git folders.
On regular folders everything works perfectly, but when I get to a git folder the terminal cursor is 4 columns to the left of where it was supposed to be. I know it was a bad description, but it's easy to reproduce and, hopefully, the attached screenshot will help.

I'm using arch linux, awesome and terminator.
deepinscreenshot20160204100658

Most helpful comment

I wrote the wedisagree theme a fair while ago... Good to see it being used by others! Let me know if it needs updating as I haven't used zsh in a while.

All 3 comments

When I've seen stuff like this before, it's often been an issue with communicating character widths to the terminal: either non-printing (0-width) characters not being properly escaped, or the terminal and your font not agreeing on how wide characters are.

wedisagree looks fine for me in Terminal.app and iTerm2 on OS X 10.9.5. (Except for the RPROMPT shifting around a couple characters when resizing the terminal.)

screen shot 2016-02-04 at 10 24 27 pm

It doesn't look like there are any unescaped non-printing characters in wedisagree. (Unless they're hidden in the ZSH_THEME_TIME_SINCE_* variables.) These are usually the color-setting escape sequences. In wedisagree, it looks like they're all properly escaped with the zsh prompt expansion %{...%} escapes.

It could be that Terminator thinks that some of those special characters in the RPROMPT are wider than your font thinks they are, such as ☂, ☀, and 𝝙. Then the terminal or curses could be mis-counting how many characters it needs to allot to that RPROMPT section, and how many characters it needs to move the cursor back to get back to the original location. The fact that the right prompt is right-aligned a few characters short of the right side of the terminal is consistent with this.

To test this out, make a customized copy of wedisagree and replace those characters with regular English letters. They're in this section. Also try out this theme in a couple other terminals and see how it behaves.

If that fixes things, then you've probably got a terminal/font width disagreement. (Or an issue with curses or a similar library.) This could be a configuration or application problem.

It could be that you have your locale configured for a single-byte encoding. Then, when there are multibyte characters like those special symbols used, the terminal or cursor library over-counts how many characters are being displayed. Check your locale output and make sure that it's a UTF-8 locale, and that Terminator supports that. And check that your Terminator profile is set up for UTF-8, and not ASCII or something else.

Or if you are set up for UTF-8. it could be that Terminator expects those special characters to be multiple cells wide when displayed. That's not something you could fix in OMZ or configuration; you'd need to report that to Terminator.

That's right! My terminal locale was wrong.
Setting

export LC_ALL=pt_BR.UTF-8
export LANG=pt_BR.UTF-8

on my .zshrc solved the problem, even though my config on /etc/locale.gen was correct.

I wrote the wedisagree theme a fair while ago... Good to see it being used by others! Let me know if it needs updating as I haven't used zsh in a while.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samsondav picture samsondav  ·  3Comments

faxotherapy picture faxotherapy  ·  3Comments

Cabbagec picture Cabbagec  ·  3Comments

nimmoadam picture nimmoadam  ·  3Comments

sohocoke picture sohocoke  ·  3Comments