voku/dotfiles

line wrapping issue on non-utf8 systems

Closed this issue · 4 comments

The fancy PS1 contains some utf-8 character sequences, e.g. ICON_FOR_TRUE or ICON_FOR_ARROW_RIGHT. As long as the locale is set to some utf8 dialect, prompt length calculation is correct. As soon as the locale is changed to C or de_DE@euro, like

$ export LC_ALL=C

there will be an issue for commands which spawns more than one line: the arrow up key to review such a long command from history will garble the prompt. The command is also not completely shown.

If the ICONs are all true one character sequences, everything is fine under both types of locales.

How to solve this? Stick to pure ASCII characters?

voku commented

maybe we can force to use UFT-8 -> 84bb94b#diff-2

... and if it fails, then we use the ASCII icons -> 8e1a43d

Hmm, forcing a utf-8 locale is bad for people who don't want utf-8 as default:-)
Sometimes people change their locale temporarly for a certain task

Personally i stay with ASCII icons even in a utf8 locale. I don't like my prompt having different "styles" ;-) I just wanted to make you aware of that problem.

voku commented

Sorry! I wrote "forcing" but I have scripted a simple loop with this pattern "pattern=".{2,2}_.{2,2}.(UTF-8|UTF8|utf-8|utf8)$"" -> "no" force! ;)

Hmm, your code does first a "grep -i utf", then your pattern choose the first matching one. In my opinion that's "forcing to UTF" :-) The user should be able to set the desired locale.