2

I have a custom bash configuration that I install on many different machines, and this includes a custom $PS1, which is generated by a script, and ends up like this :

\[\e[0;33m\][\!] $(if [[ $? == 0 ]]; then echo "\[\e[0;32m\]✓"; else echo "\[\e[0;31m\]✗"; fi) \[\e[1;33m\]\u\[\e[1;36m\]@\h \[\e[1;32m\]\w \[\e[1;32m\]\$\[\e[00m\]

Which is a little bit ugly, but it appears that the problem is only caused by the ✓ and ✗ characters; infact, replacing them by o and n resolves the problem, and making

PS1='✓'

still suffers it.

The problem is that when I type a command long enough to reach the limit of my terminal, instead of continuing on the next line, it overlaps the prompt and the beginning of the command. The funny thing if that it only overlaps the first time, then it normally continues on the next line.

The machine on which this happens is a brand new Debian 8 Jessie Virtual Machine, made on a Debian 8 Hypervisor running Xen4.4, with the xl toolstack. I make several other identical VMs and had the same result. However, I don't have this problem on any physical Debian machine I tried (including my Dom0). I also tried on a Ubuntu15.04 VM, and it doesn't suffer the problem either.

I also noticed that this problem happens both on a ssh connexion and via the serial console.

Does anybody have any idea about what's happening ?

toadjaune
  • 801
  • 1
  • 6
  • 11
  • My guess is wrong length calculation of the special characters. Anyway, this probably better belongs to SuperUser. – 4ae1e1 Jan 11 '16 at 01:57
  • In this answer: http://stackoverflow.com/a/23533623/1566221 there is a little program you can use to check the locale settings for unicode characters. You need to use the hex codes for the characters, which are 2713 (✓) and 2717 (✗). It should say, for example, `Code 2713: width 1 punct graph print`. – rici Jan 11 '16 at 03:34
  • Infact, the problem seems to be somewhere here, it tells me : `Code 2713: width -1` on my remote machine, while I have the expected `Code 2713: width 1 punct graph print` on my local machine. – toadjaune Jan 22 '16 at 01:37
  • Just patched my `i18n_ctype` file and I'm getting correct width of my char, however when I use it in PS1, problems remain. – Aleksandr Makov Sep 23 '19 at 22:06

0 Answers0