justjanne / powerline-go

A beautiful and useful low-latency prompt for your shell, written in go
GNU General Public License v3.0
2.75k stars 270 forks source link

Bash wrapping issue on Debian 10 container #200

Open ankitbko opened 4 years ago

ankitbko commented 4 years ago

image

As you can see in the container the wrapping does not happen. It works in Ubuntu based container fine.

Use this docker image to reproduce the issue FROM mcr.microsoft.com/dotnet/core/sdk:3.1. https://hub.docker.com/_/microsoft-dotnet-core-sdk?tab=description

andrzejnovak commented 4 years ago

Have the same issue though it only seems to happen sometimes. Not sure what the trigger is

ankitbko commented 4 years ago

In the Debian container? Happened to me always.

andrzejnovak commented 4 years ago

I am having this problem with Win10 using the new terminal

ankitbko commented 4 years ago

@andrzejnovak Are you using powershell? It works fine for bash on WSL 2 using the new Terminal.

andrzejnovak commented 4 years ago

@ankitbko Nah using bash, same problem also using hyper

thousandtyone commented 4 years ago

Same issue on arch linux.

justjanne commented 4 years ago

Thus seems to be an issue with your Terminal emulator, as neither the IntelliJ emulator, Konsole, iTerm, Gnome Terminal, xTerm, nor the linux tty console have issues with this.

theravengod commented 4 years ago

It occurs on Konsole in Manjaro Linux (Arch based). If I set the default Linux prompt the issue doesn't occur, so it's not a Terminal issue. This is my prompt : PS1="$(/usr/bin/powerline-go -cwd-max-depth 4 -modules user,cwd,git,venv,jobs,exit,root -error $?)"

ankitbko commented 3 years ago

Started happening again on a new Linux VM with containors in it. Any idea on how to debug this?

eternalphane commented 3 years ago

This is caused by wrong length calculation of special characters (e.g. U+E0B0 ).

Here's a hacky fix:

# ~/.bashrc

function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -newline -error $?)"
    # add the following line
    PS1="${PS1//$'\356\202\260'/$'\[$(tput sc)\] \[$(tput rc)\356\202\260\]'}"
    # or more intuitive
    # PS1="${PS1///'\[$(tput sc)\] \[$(tput rc)\]'}"
}
andrzejnovak commented 3 years ago

@eternalphane looked promising for a moment, but it doesn't solve it for me

ankitbko commented 3 years ago

Ya didn't work for me either. But maybe the root cause is regarding wrong length calculation. Is there a generic solution for this?

eternalphane commented 3 years ago

@andrzejnovak @ankitbko maybe you should check the output of printf "%q\n" "$GOPATH/bin/powerline-go -newline -error $?" (or whatever in your .bashrc) to find the actual issue in your case. Alright, finally found a promising solution: set LC_ALL to C.UTF-8 (or make sure LC_CTYPE is utf-8 locale). Maybe this should be added to the doc.

dswij commented 3 years ago

I can't reproduce the issue, but this is a known issue with prompt length / window size. I would try looking at https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly

eternalphane commented 3 years ago

@dswij can I see your output of locale? I just want to confirm if it's related to locale settings.

dswij commented 3 years ago

@dswij can I see your output of locale? I just want to confirm if it's related to locale settings.

UTF-8

eternalphane commented 3 years ago

UTF-8

Just checked with a fresh installed Debian 10 in Hyper-V, the default LC_ALL is empty. Then I'm wondering why my LC_ALL is assigned a value...😕

andrzejnovak commented 3 years ago

Changing the LC_ALL doesn't seem to affect this for me

eternalphane commented 3 years ago

Changing the LC_ALL doesn't seem to affect this for me

@andrzejnovak what's the output of test=''; echo ${#test} on your machine?

andrzejnovak commented 3 years ago

@eternalphane 1

eternalphane commented 3 years ago

@andrzejnovak emmm... I have no idea what's happening on your side

ankitbko commented 3 years ago

Changing the LC_ALL doesn't seem to affect this for me

@andrzejnovak what's the output of test=''; echo ${#test} on your machine?

Mine also shows 1

codewest commented 3 years ago

This happens for me on Fedora 34 with bash. No containers involved. Happens with xfce4-terminal and gnome-terminal.

Looks to be a bug with the termtitle module. If I don't enable that in my -modules ... list, I no longer experience the bug.

gabrielfsousa commented 3 years ago

any solution ?, im having this issue also

ashleyghooper commented 8 months ago

The "hacky fix" kindly provided by @eternalphane worked for me.

daltonv commented 3 months ago

I think @dswij is on the right track. At least for my issue.

My image was always using the default C locale so it did not have the utf-8 characters. When I set LANG and LC_ALL to "C.UTF-8" I no longer had issues with long lines wrapping in the terminal.

Setting the locale to en_US.UTF-8 would probably work too, but then you have to install that locale.