Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Sumit Saini
Level 1
Level 1
Posts: 6
Joined: Tue Sep 14, 2021 8:59 am

Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by Sumit Saini »

I noticed that whenever i resize my terminal window to a size that is smaller than that of a terminal prompt, instead of wrapping the overflown prompt to the next line, copies of the prompt are printed. The images are attached below

Normal Terminal Prompt
Screenshot from 2021-09-21 04-07-13.png

After resizing the window by dragging the window border
Screenshot from 2021-09-21 04-07-26.png

Screenshot from 2021-09-21 04-07-55.png


The PS1 is set as shown below,

Code: Select all

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
I tried to copy the .bashrc file from a live boot but that had the same problem.


SYSTEM INFO

Code: Select all

System:    Kernel: 5.11.0-34-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 5.0.5 
           wm: muffin dm: LightDM Distro: Linux Mint 20.2 Uma base: Ubuntu 20.04 focal 
Machine:   Type: Laptop System: LENOVO product: 82LM v: IdeaPad 5 14ALC05 serial: <filter> 
           Chassis: type: 10 v: IdeaPad 5 14ALC05 serial: <filter> 
           Mobo: LENOVO model: LNVNB161216 v: SDK0Q55722 WIN serial: <filter> UEFI: LENOVO 
           v: G5CN17WW(V1.05) date: 04/22/2021 
Battery:   ID-1: BAT1 charge: 38.0 Wh condition: 57.8/56.5 Wh (102%) volts: 12.7/11.5 
           model: 0x53 0x4D 0x50 0x00 0x32 0x30 0x 0x4C 0x31 0x39 0x4D 0x33 0x50 0x5650 
           serial: <filter> status: Charging 
CPU:       Topology: 8-Core model: AMD Ryzen 7 5700U with Radeon Graphics bits: 64 type: MT MCP 
           arch: Zen rev: 1 L2 cache: 4096 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 57493 
           Speed: 1397 MHz min/max: 1400/1800 MHz Core speeds (MHz): 1: 1397 2: 1396 3: 1929 
           4: 1929 5: 4334 6: 4341 7: 1930 8: 1930 9: 1397 10: 1396 11: 1397 12: 1397 13: 1397 
           14: 1398 15: 1952 16: 1929 
Graphics:  Device-1: AMD vendor: Lenovo driver: amdgpu v: kernel bus ID: 04:00.0 
           chip ID: 1002:164c 
           Display: x11 server: X.Org 1.20.11 driver: amdgpu,ati unloaded: fbdev,modesetting,vesa 
           resolution: 1920x1080~60Hz 
           OpenGL: renderer: AMD RENOIR (DRM 3.40.0 5.11.0-34-generic LLVM 12.0.0) 
           v: 4.6 Mesa 21.0.3 direct render: Yes 
Audio:     Device-1: AMD vendor: Lenovo driver: snd_hda_intel v: kernel bus ID: 04:00.1 
           chip ID: 1002:1637 
           Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor vendor: Lenovo 
           driver: snd_rn_pci_acp3x v: kernel bus ID: 04:00.5 chip ID: 1022:15e2 
           Device-3: AMD Family 17h HD Audio vendor: Lenovo driver: snd_hda_intel v: kernel 
           bus ID: 04:00.6 chip ID: 1022:15e3 
           Sound Server: ALSA v: k5.11.0-34-generic 
Network:   Device-1: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter vendor: Lenovo 
           driver: rtw_8822ce v: N/A port: 2000 bus ID: 03:00.0 chip ID: 10ec:c822 
           IF: wlo1 state: up mac: <filter> 
Drives:    Local Storage: total: 476.94 GiB used: 61.68 GiB (12.9%) 
           ID-1: /dev/nvme0n1 vendor: Western Digital model: PC SN530 SDBPMPZ-512G-1101 
           size: 476.94 GiB speed: 31.6 Gb/s lanes: 4 serial: <filter> 
Partition: ID-1: / size: 467.96 GiB used: 61.68 GiB (13.2%) fs: ext4 dev: /dev/nvme0n1p2 
USB:       Hub: 1-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 chip ID: 1d6b:0002 
           Device-1: 1-2:2 info: MosArt 2.4G Wireless Mouse type: Mouse driver: hid-generic,usbhid 
           rev: 1.1 chip ID: 062a:4106 
           Device-2: 1-3:3 info: Acer Integrated Camera type: Video driver: uvcvideo rev: 2.0 
           chip ID: 5986:212b 
           Hub: 2-0:1 info: Full speed (or root) Hub ports: 2 rev: 3.1 chip ID: 1d6b:0003 
           Hub: 3-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 chip ID: 1d6b:0002 
           Device-3: 3-2:4 info: SiGma Micro Keyboard TRACER Gamma Ivory type: Keyboard,HID 
           driver: hid-generic,usbhid rev: 1.1 chip ID: 1c4f:0002 
           Device-4: 3-3:2 info: Elan Micro ELAN:Fingerprint type: <vendor specific> driver: N/A 
           rev: 2.0 chip ID: 04f3:0c4d 
           Device-5: 3-4:3 info: Realtek Bluetooth Radio type: Bluetooth driver: btusb rev: 1.0 
           chip ID: 0bda:c123 
           Hub: 4-0:1 info: Full speed (or root) Hub ports: 2 rev: 3.1 chip ID: 1d6b:0003 
Sensors:   System Temperatures: cpu: 59.9 C mobo: N/A gpu: amdgpu temp: 47 C 
           Fan Speeds (RPM): N/A 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/additional-repositories.list 
           1: deb https: //dl.winehq.org/wine-builds/ubuntu/ focal main
           Active apt repos in: /etc/apt/sources.list.d/brave-browser-release.list 
           1: deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https: //brave-browser-apt-release.s3.brave.com/ stable main
           Active apt repos in: /etc/apt/sources.list.d/google-chrome.list 
           1: deb [arch=amd64] http: //dl.google.com/linux/chrome/deb/ stable main
           Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
           1: deb http: //packages.linuxmint.com uma main upstream import backport #id:linuxmint_main
           2: deb http: //archive.ubuntu.com/ubuntu focal main restricted universe multiverse
           3: deb http: //archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
           4: deb http: //archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
           5: deb http: //security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
           6: deb http: //archive.canonical.com/ubuntu/ focal partner
           Active apt repos in: /etc/apt/sources.list.d/spotify.list 
           1: deb http: //repository.spotify.com stable non-free
           Active apt repos in: /etc/apt/sources.list.d/sublime-text.list 
           1: deb https: //download.sublimetext.com/ apt/stable/
           Active apt repos in: /etc/apt/sources.list.d/teams.list 
           1: deb [arch=amd64] https: //packages.microsoft.com/repos/ms-teams stable main
           Active apt repos in: /etc/apt/sources.list.d/vivaldi.list 
           1: deb http: //repo.vivaldi.com/stable/deb/ stable main
           Active apt repos in: /etc/apt/sources.list.d/vscode.list 
           1: deb [arch=amd64,arm64,armhf] http: //packages.microsoft.com/repos/code stable main
Info:      Processes: 350 Uptime: 43m Memory: 7.19 GiB used: 2.67 GiB (37.1%) Init: systemd v: 245 
           runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 Client: Unknown python3.8 client inxi: 3.0.38 
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by mikeflan »

If you simply reduce the size of window1 and you get window2, that does not happen on my LM19.3 system. I can see in your case that it removes 1-2 characters at the end every time the command prompt is repeated.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by Flemur »

Sumit Saini wrote: Mon Sep 20, 2021 7:05 pm The PS1 is set as shown below,

Code: Select all

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
That (lack of) wrapping is pretty funky, but I've always thought the default prompts were pretty lame because you know the name of your machine, etc. and there's no reason to see it all the time (the default PS1 is based on an environment where people login to multiple machines and each machine has multiple users, which is hardly the case with most home desktops)

Try changing your PS1 to something useful like:
PS1="$PWD : "
or you can use something like \w to get the last dir in the PWD (e.g. just "Desktop $ ").
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by rene »

Reproduced. Initially one would think this a terminal bug but reproduced both on 20.2 Xfce and 20.2 Cinnamon, i.e., xfce4-terminal and gnome-terminal. If mikeflan tested correctly that it doesn't happen on his 19.3 system that seems to say it's a new bug. Where, I'd have no idea. Setting or unsetting bash' checkwinsize option doesn't help, nor does changing PS1 to something simple without any escape characters: as long as it's long enough to be longer than a minimal terminal width allows for, resizing the terminal to a width less than the for the prompt needed width has this issue pop up.

xenopeek tends to be best in knowing about known issues and/or relaying up new, real issues; let's see if he has an idea and/or can coach this up the bug-reporting stack. I would expect it to also be present in Ubuntu 20.04...
xenopeek wrote: Mon Sep 20, 2021 11:21 am
[EDIT] Also seemingly not influenced by set horizontal-scroll-mode on or off in ~/.inputrc (readline config).
User avatar
xenopeek
Level 25
Level 25
Posts: 29614
Joined: Wed Jul 06, 2011 3:58 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by xenopeek »

The same thing happens on Ubuntu 20.04 (package base for Linux Mint 20.x) and also in upcoming Ubuntu 21.10 (not used by Linux Mint). This is not an issue introduced by Linux Mint.

The PS1 on both is:

Code: Select all

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
Bash version on 21.10 is: 5.1-3ubuntu1
Gnome Terminal: 3.38.1-1ubuntu1

The same happens on Arch Linux with bash 5.1.008 and gnome-terminal 3.40.3.

I think this is a bash bug.

I tried reproducing the same with dash and can't reproduce it with that. On my system dash doesn't have a default prompt other than $ but I set it with:
PS1='$USER@$HOSTNAME!$0!:$PWD/\$ '
Then resizing the terminal it neatly folds the text on long path without this weirdness. Running the same command in a bash session the issue described in this topic happens. So Gnome Terminal doesn't look to be the problem, but bash.

Edit: tried the same test in Alacritty terminal and bash does the same weirdness while dash is fine. This is for sure a bash issue.
Image
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by rene »

Thanks for checking; thought it fairly weird that I didn't find it on a Google search if it were as widespread as that. But, well, seems to want to be reported to bash then, although probably best still via Ubuntu: https://bugs.launchpad.net/ubuntu/+source/bash

Mentioning all that xenopeek just did will be good...
ujsk07
Level 1
Level 1
Posts: 1
Joined: Tue Sep 21, 2021 12:11 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by ujsk07 »

You can try to do any of these two things to resolve it :
1. Change the value of PS1 in this block of code :-
case "$TERM" in
xterm*|rxvt*)
PS1="$PS1\n> " # change this value
;;
*)
;;
esac

2. To make its look more like zsh , you can do remove if [ "$color_prompt" = yes ]; then block and case "$TERM" in block of code , and just insert
PS1="\[\033[01;32m\]┌──\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\[\033[01;32m\]└─\[\033[00m\]$ "

Just it will create a new line where you can play with your commands !
Image
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by rene »

As mentioned, changing PS1 does not "resolve" this in any fundamental sense; any prompt that ends up too long for the window width triggers the issue. Just e.g. set PS1="foobarfoobar..." long enough to test such. With the standard PS1, simply going into e.g. /usr/share/doc/libmoox-aliases-perl or any other long path and dragging the right edge of the terminal window left and right a few times has you end up with the below. It's a bug somewhere, and any adjustment of PS1 is a workaround to avoid hitting it at best, not a resolution.

Mint 20.2 Xfce, but same happens on 20.2 Cinnamon:
.
Attachments
bashbug.png
Sumit Saini
Level 1
Level 1
Posts: 6
Joined: Tue Sep 14, 2021 8:59 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by Sumit Saini »

ujsk07 wrote: Tue Sep 21, 2021 12:27 pm You can try to do any of these two things to resolve it :
1. Change the value of PS1 in this block of code :-
case "$TERM" in
xterm*|rxvt*)
PS1="$PS1\n> " # change this value
;;
*)
;;
esac

2. To make its look more like zsh , you can do remove if [ "$color_prompt" = yes ]; then block and case "$TERM" in block of code , and just insert
PS1="\[\033[01;32m\]┌──\[\033[00m\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\[\033[01;32m\]└─\[\033[00m\]$ "

Just it will create a new line where you can play with your commands !
Image

Thank you very much this Workaround worked.
Having a multi line prompt is a nice way to avoid that bug even in bash(so far!).

But the problem still persists for single line prompts.
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by mikeflan »

You guys don't need this, but if you want to see how LM 19.3 behaves, look at this:
http://www.mflan.com/temp/term2.mp4

As always, it's best to save that file to your computer before paying it.

This problem does not affect LM 19.3 if I understand the problem correctly.
Sumit Saini
Level 1
Level 1
Posts: 6
Joined: Tue Sep 14, 2021 8:59 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by Sumit Saini »

mikeflan wrote: Tue Sep 21, 2021 5:16 pm You guys don't need this, but if you want to see how LM 19.3 behaves, look at this:
http://www.mflan.com/temp/term2.mp4

As always, it's best to save that file to your computer before paying it.

This problem does not affect LM 19.3 if I understand the problem correctly.
Yes you are correct. Which version of Bash are you using ?
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by mikeflan »

Gnome Terminal 3.28.1
Sumit Saini
Level 1
Level 1
Posts: 6
Joined: Tue Sep 14, 2021 8:59 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by Sumit Saini »

mikeflan wrote: Tue Sep 21, 2021 5:53 pm Gnome Terminal 3.28.1
Ah I meant the version of the bash program , run the following command and post the output

Code: Select all

bash --version
mikeflan
Level 17
Level 17
Posts: 7150
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by mikeflan »

Bash version:

Code: Select all

$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
User avatar
xenopeek
Level 25
Level 25
Posts: 29614
Joined: Wed Jul 06, 2011 3:58 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by xenopeek »

I think this is a bug in the readline library. Bash uses that for the fancy line editor. Other shells don't use readline.

You can use bash without readline. As a test, this command starts a new bash session with a very long prompt, doesn't use your .profile or .bashrc files and does not use the readline library:
PS1='a very, very, VERY, *V*E*R*Y* looooooooong prompt$ ' bash --noprofile --norc --noediting
After running that I can resize the window without this issue happening.

Removing the --noediting from the end of above command, the issue happens again.
Image
User avatar
xenopeek
Level 25
Level 25
Posts: 29614
Joined: Wed Jul 06, 2011 3:58 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by xenopeek »

I've reported the issue on the bash bug tracker, with a short video showing the issue: https://savannah.gnu.org/support/index.php?110543

I hope that's the right place to report it. Readline website says it's developed alongside bash and the maintainer is the same person. Readline doesn't have a bug tracker.
Image
t42
Level 11
Level 11
Posts: 3744
Joined: Mon Jan 20, 2014 6:48 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by t42 »

Same issue is in Debian 12
bash 5.1.8
readline-common 8.1-2
readline-editor: Installed: (none) Candidate: (none)
-=t42=-
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by rene »

xenopeek wrote: Wed Sep 22, 2021 6:01 am I've reported the issue on the bash bug tracker, with a short video showing the issue: https://savannah.gnu.org/support/index.php?110543
Thanks much for coaching this up; can't personally stand bugzilla's (oh, and good find as to readline).

But; is it just me, or is nothing happening in that video? I just see a static terminal window with your long prompt; nothing happening
Last edited by rene on Wed Sep 22, 2021 7:23 am, edited 1 time in total.
User avatar
xenopeek
Level 25
Level 25
Posts: 29614
Joined: Wed Jul 06, 2011 3:58 am

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by xenopeek »

That's you. The video is a few seconds long, showing me grabbing the window border and dragging it to the left to make the issue appear.

Can you see it here? https://imgur.com/CrVOvgk
Image
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Terminal Prompt line wrap not working (Bash version 5.0.17(1)-release)

Post by rene »

No, can also not, in Firefox 92.0 on Mint 20.2 with nothing but uBlock Origin installed and even with uBlock Origin disabled. I can though after downloading the file, so as long as it's me: fine; I'll figure that out some other time; let's not muddy this thread with...

... oh, wait, I did disable any and all animated GIF support at least a year or two ago. Anyways, never mind; just wanted to make sure that the video was good; that it was me. Thanks again for posting it.
Locked

Return to “Beginner Questions”