-1

I wanted to put the Unicode character Δ into PS1, but when I did, when typing in long commands, the terminal wouldn't wrap to a newline but would overwrite the current line!

The problem doesn't occur when I remove the Unicode character, and I am pretty sure I escaped everything.

export PS1="Δ "

The terminal overwriting the current line

How do I fix this?

Term. Info:

$BASH_VERSION => 5.0.16(1)-release
        $TERM => xterm-256color
! stty
speed 38400 baud; line = 0;
-brkint -imaxbel iutf8

P.S. the solution at bash prompt not wrapping as expected also resulted in odd behavior, due to the fact that ignoring the Unicode character also results in an incorrect character count.

Bill
  • 131
  • 3
  • Does it misbehave even if you remove all the colours and leave only ascii and one Δ in PS1? – choroba Mar 24 '20 at 00:05
  • @choroba Yes, even with only one ascii and one unicode, it still overwrites the current line – Bill Mar 24 '20 at 00:15
  • I cannot reproduce. Please add info about your bash version (`echo $BASH_VERSION`), the terminal you run this in (`echo $TERM`), and the stty settings (`stty`). –  Mar 24 '20 at 00:21
  • @mosvy Ok, I have edited the question – Bill Mar 24 '20 at 00:24
  • Try setting `LC_ALL= LC_CTYPE=en_US.UTF-8` in the shell (no need to export them) and see if it fixes it. –  Mar 24 '20 at 00:25
  • I got the error `bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8)` – Bill Mar 24 '20 at 00:29
  • Also, what font does you Terminal use? – choroba Mar 24 '20 at 00:29
  • 1
    What does the `locale` command say? Try setting it to any utf locale you have available (`locale -a` should give you a list). –  Mar 24 '20 at 00:30
  • I'm on Parrot OS, and I have posted my `locale` output on pastebin here: [https://pastebin.com/CpDL7dRb](https://pastebin.com/CpDL7dRb) – Bill Mar 24 '20 at 00:32
  • My terminal uses the default system font @choroba – Bill Mar 24 '20 at 00:32
  • It worked! My locale was set to a non-existing locale, so I changed it to one of the locales in the list `C.UTF-8`, and it worked! Thanks! – Bill Mar 24 '20 at 00:34

1 Answers1

3

As @mosvy said in the comments, the problem was the locale setting!

My locale was set to a non-existing locale, so I changed it to one that actually exists, which in my case was C.UTF-8 (get a list of locales with locale -a).

export LC_ALL="C.UTF-8"
Bill
  • 131
  • 3