sdbbs
sdbbs

Reputation: 5480

Restore terminal ANSI color behaviour in bash after failure caused by user program?

I use bash under MINGW64 on Windows 10. I had compiled myself a version of wcalc some years ago, which used to work fine for me - but recently I noticed that it breaks ANSI coloring in the terminal completely:

terminal screenshot

... that is, instead of getting the following prompt with colors:

user@DESKTOP-PC 2025-02-25|03:41:27 MINGW64 ~
$ 

... I get this mess of characters, instead of the prompt (after trying to run wcalc 2+2):

←[?2004h←]0;~
←[32muser@DESKTOP-PC ←[36m2025-02-25|03:41:56←[0m ←[35mMINGW64←[0m ←[33m~←[0m
←[1m$←[0m

You may notice in the screenshot, that running the reset command (which usually solves all my terminal behavior woes) does not help in restoring the correct behavior.

Would anyone know what command I could use, to restore the correct ANSI color character behavior of the terminal, when I end up in such a state (currently I have no other option but closing and restarting that terminal)


EDIT: I discovered that the problem was that there was an old msys-2.0.dll and a few others in the same folder as wcalc.exe; these old DLLs apparently conflicted with the newer DLLs - so the overall solution for me was simply to remove the old dll's from the wcalc folder, and copy the new DLLs from MSYS2 /bin there instead.

However it would still be good to know if it is possible to recover from the messy terminal color situation as described above with a command; so I hope someone can answer that.

Upvotes: 0

Views: 24

Answers (1)

dash-o
dash-o

Reputation: 14468

Short Answer: Not with MINGW64, which uses DLL to process the ANSI escape sequences for colors. Alternative are newer terminal emulator, which have the ASCII escape sequences built into the terminal.

See: Escape sequences unprocessed under the "cygwin" terminal

Upvotes: 0

Related Questions