Issue with line wrapping #13730

Closed
opened 2026-01-31 03:50:33 +00:00 by claunia · 4 comments
Owner

Originally created by @vlad-tura on GitHub (May 5, 2021).

Windows Terminal version (or Windows build number)

Microsoft Windows NT 10.0.19041.0

Other Software

Debian (inside wsl)

Steps to reproduce

  1. Open up any WSL distro (tested on Debian)
  2. Write a line long enough that is should wrap (doesn't work if you copy-paste the line, you need to type it).
    xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Expected Behavior

The caret should continue on the next line.

Actual Behavior

The caret goes to the beginning of the current line

Screen Recording 2021-05-05 at 08 04 06 82 PM

Originally created by @vlad-tura on GitHub (May 5, 2021). ### Windows Terminal version (or Windows build number) Microsoft Windows NT 10.0.19041.0 ### Other Software Debian (inside wsl) ### Steps to reproduce 1) Open up any WSL distro (tested on Debian) 2) Write a line long enough that is should wrap (doesn't work if you copy-paste the line, you need to type it). `xxxxxxxxxxxxxxxxxxxx` xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ### Expected Behavior The caret should continue on the next line. ### Actual Behavior The caret goes to the beginning of the current line ![Screen Recording 2021-05-05 at 08 04 06 82 PM](https://user-images.githubusercontent.com/39374094/117181453-ee296500-addd-11eb-8ef1-cf89d9b3a8c1.gif)
claunia added the Needs-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 03:50:33 +00:00
Author
Owner

@DHowett commented on GitHub (May 5, 2021):

This looks like the classic "bash is not aware of the escape sequences you put into your prompt" issue.

From stack overflow: terminal prompt not wrapping correctly-

Non-printable sequences should be enclosed in \[ and \]. Looking at your PS1 it has a unenclosed sequence after \W. But, the second entry is redundant as well as it repeats the previous statement "1;34".

From Arch wiki-

Note: Wrapping the tput output in \[ \] is recommended by the Bash man page. This helps Bash ignore non-printable characters so that it correctly calculates the size of the prompt. The wrap will not work with command substitution, in which case the raw \1 \2 must be used.

Can you share the output of echo $PS1?

@DHowett commented on GitHub (May 5, 2021): This looks like the classic "bash is not aware of the escape sequences you put into your prompt" issue. From [stack overflow: terminal prompt not wrapping correctly](https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly)- > Non-printable sequences should be enclosed in \\[ and \\]. Looking at your PS1 it has a unenclosed sequence after \W. But, the second entry is redundant as well as it repeats the previous statement "1;34". From [Arch wiki](https://wiki.archlinux.org/title/Bash/Prompt_customization#Bash_escape_sequences)- > Note: Wrapping the tput output in \\[ \\] is recommended by the Bash man page. This helps Bash ignore non-printable characters so that it correctly calculates the size of the prompt. The wrap will not work with command substitution, in which case the raw \\1 \\2 must be used. Can you share the output of `echo $PS1`?
Author
Owner

@vlad-tura commented on GitHub (May 5, 2021):

You're right, it really does look like that
PS1="\e[0;32m[\u@\h \W]\$ \e[m"

@vlad-tura commented on GitHub (May 5, 2021): You're right, it really does look like that `PS1="\e[0;32m[\u@\h \W]\$ \e[m"`
Author
Owner

@DHowett commented on GitHub (May 5, 2021):

If you change it to this ...

export PS1="\[\e[0;32m\][\u@\h \W]\$ \[\e[m\]"

... how does it change your wrapping issue?

@DHowett commented on GitHub (May 5, 2021): If you change it to this ... ``` export PS1="\[\e[0;32m\][\u@\h \W]\$ \[\e[m\]" ``` ... how does it change your wrapping issue?
Author
Owner

@vlad-tura commented on GitHub (May 5, 2021):

Yep, just did this and it works, thanks a lot!
export PS1="\[\e[0;32m[\u@\h \W]\$\] \[\e[m\]"

@vlad-tura commented on GitHub (May 5, 2021): Yep, just did this and it works, thanks a lot! `export PS1="\[\e[0;32m[\u@\h \W]\$\] \[\e[m\]"`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13730