hykilpikonna / hyfetch

🏳️‍🌈 🏳️‍⚧️ Neofetch with LGBTQ+ pride flags!
MIT License
1.27k stars 96 forks source link

Git Bash on Windows renders control characters in setup #45

Closed Kwonunn closed 1 year ago

Kwonunn commented 1 year ago

Description

When first configuring hyfetch the terminal renders control characters instead of interpreting them: image

This happens both in VSCode's integrated terminal as well as the Windows Terminal. Running in MinTTY does work:

image

After having actually run through the config, running the program does work for some reason...

image

I have looked through the source, but I can't fix it.

Neofetch version

Just fetched master

Config file

GlobalConfig(color_mode='rgb', override_distro=None, debug=True, is_light=False)

hykilpikonna commented 1 year ago

hmm weird, git bash should be using mintty internally if I remember correctly, IDK why it is doing that.

Also, the color escape sequences used in the config screen should be the same with the actual rendering screen, just that the actual rendering is printed by bash while the config screen is printed by python... it might be some implicit conversion that git bash is doing.

Can you try running if each of these can print colors in git bash?

python3 -c "print('\033[1;33mTest Colors\033[0m;')"
bash -c "printf '\033[1;33mTest Colors\033[0m;'"
Kwonunn commented 1 year ago

image image

To me this seems like Python might be outputting 'raw' strings or something

hykilpikonna commented 1 year ago

Both work totally fine on Unix.

image

Since Windows' terminal emulator doesn't natively support Xterm color escape sequences but have its own set of color interface, I would guess that git bash is probably doing some implicit conversion, and since windows Python isn't doing the conversion, python output isn't colored on Windows.

I have no idea of how to work around this since I'm not familiar with how Windows cmd's color coding works... maybe we can try colorama's conversion?

pip install colorama
python3 -c "import colorama; colorama.just_fix_windows_console(); print('\033[1;33mTest Colors\033[0m;')"
R3AP3 commented 1 year ago

this may be an issue with msys/mingw64... i had this problem with multicolor support for my msys shell on windows too and fixxed it by literally making pacman -Syu and that fixxed it.

randomly found this issue and it remembered me of that issue i had. This is not an issue with hyfetch mostlikely (even tho i never used it until now)

Kwonunn commented 1 year ago

image Colorama does work, so using that seems like a good fix