WhitewaterFoundry / Fedora-Remix-for-WSL

Fedora Remix for Windows Subsystem for Linux.
Other
693 stars 51 forks source link

Fedora 39 Prompt defaulting to `-bash-5.2#` -> `\s-\v\$` #214

Open ElvenSpellmaker opened 6 months ago

ElvenSpellmaker commented 6 months ago

Describe the bug Since Fedora 39, the prompt now displays an unhelpful -bash-5.2# instead of something like root@<machine id>:~#

Because bash-color-prompt is installed since 39 the TERM needs to be xterm-color or xterm-256color for this to work. The default is xterm which forces an unhelpful prompt as it's no longer set:

# only set for color terminals and if PS1 unchanged from bash or fedora defaults
if [ '(' "$PS1" = "[\u@\h \W]\\$ " -o "$PS1" = "\\s-\\v\\\$ " ')' -a "${TERM: -5}" = "color" -o -n "${prompt_color_force}" ]; then

It'd be helpful to either set the TERM to xterm-256color by the distro before this script is called, i.e. in 00-remix.sh, or there should be a script that runs after to set a monochrome version of 38's prompt in lieu if the user hasn't got a TERM set with color in it.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade from Fedora 38 to 39 using the insturctions here: https://www.whitewaterfoundry.com/blog/2023/11/18/fedora-remix-for-wsl-39-released
  2. Restart your shell and watch the prompt change from a useful prompt into -bash-5.2#

Expected behavior A nicer prompt should be set up by bash-color-prompt.sh by default.

Screenshots Without image

With adding TERM image

Additional context

Basic Troubleshooting Checklist

[x] I have searched Google for the error message. [x] I have checked official WSL troubleshooting documentation: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#confirm-wsl-is-enabled. [x] I have searched the official Microsoft WSL issues page: https://github.com/Microsoft/WSL/issues. [x] I have searched the WLinux issues page: https://github.com/WhitewaterFoundry/WLinux/issues. [x] I have reset WLinux: Settings->Apps->Apps & features->WLinux->Advanced Options->Reset. [x] I have disabled and re-enabled WSL in Windows Features. [x] I have run Windows 10 updates and restarted.

What other troubleshooting have you attempted?

Insert here: Adding export TERM="xterm-256color" just before the if statement fixes this, but it should be enabled out of the box. Or it should at least generate the same monochrome prompt as before, allowing users to enable colour later.

Fedora Remix for WSL Version

# cat /etc/fedora-release
Generic release 39 (Generic)

Insert here:

Windows Build

OS Name:                   Microsoft Windows 11 Enterprise
OS Version:                10.0.22621 N/A Build 22621
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
BIOS Version:              Dell Inc. 1.18.0, 12/09/2023

For help on retrieving: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#check-your-build-number

crramirez commented 6 months ago

Hello @ElvenSpellmaker ,

I have been testing with many installations, WSL versions, with and without Store version, many distros and always echo $TERM gives me xterm-256color, this is set at WSL level. We can add the configuration to the 00-remix.sh, but could you check first if you have a script that maybe is setting the TERM variable to xterm? I don't want to force this value and break any other user's configuration.

Regards, Carlos

ElvenSpellmaker commented 6 months ago

Hey @crramirez, I can try to debug further, but I'm almost sure I don't set it anywhere beforehand, I wouldn't want it to be just xterm so if it's something running before, it's not intention and isn't me!

ElvenSpellmaker commented 6 months ago

Ahh OK I see the problem, it's partly PEBCAK (🤦🏻‍♂️) and partly that the default prompt since the colour has been introduced for non-colour terminals is set to the default useless rather than the previous one which is confusing. >.>;

it's Terminal level thing (wsltty in my case, I have it changed for mintty but forgot to change for that one too), and I changed it to xterm-256color and it works fine.

Really at its core, it's a Fedora problem and they should provide a better default prompt for those on xterm instead of xterm-256color. Basically since the introduction of bash-color-prompt it no longer handles xterm for a monochrome prompt as well which is very surprising but not a Fedora Remix specific problem, sorry about that, you jogged my memory...