Windows Terminal not properly resetting default colors altered within WSL #17850

Open
opened 2026-01-31 05:56:19 +00:00 by claunia · 0 comments
Owner

Originally created by @RoiEXLab on GitHub (Jul 3, 2022).

Windows Terminal version

1.14.145 (the latest Windows Store preview)

Windows build number

10.0.19044.1766

Other Software

ncurses (probably not necessary, but used for the reproducer)
WSL using Ubuntu 20.04

Steps to reproduce

You need to have a working C++ compiler and ncurses installed (sudo apt install libncurses-dev), also I'm using colortest (sudo apt install colortest) to illustrate the before and after differences.

Run colortest-256 in the terminal. This should produce an output similar to this:
Color Example before

Then you create this file called "MinimalExample.cpp"

#include <algorithm>
#include <iostream>
#include <ncurses.h>
#include <unistd.h>


int main() {
  initscr();
  start_color();

  for (int color = 0; color < std::min(16, COLORS); color++) {
    init_color(color, 1000, 0, 0);
  }
  refresh();
  usleep(500000);
  // separates initialization from tear down in stdout
  std::cout << std::endl << std::endl;
  endwin();
}

And compile it using g++ (clang should work too in theory, haven't tested it) using g++ ./MinimalExample.cpp -lncurses.
Then run it using ./a.out.

Expected Behavior

Using a regular bash shell inside a Ubuntu 20.04 VM colortest-256 has the same output regardless if the example code has been run. (This is also the case when using the VS Code Terminal with the WSL integration.) Within the application the colors 0-15 are correctly changing, it should just reset properly when ending the application.

Actual Behavior

Using the standard terminal (conhost.exe) and within Windows Terminal this causes the 16 standard colors to be replaced with #F00. This makes colortest-256 output this result:
Colortest output after

When looking at stdout the example code creates something along those lines (the output is escaped to be readable):

ESC[?1049hESC[22;0;0tESC[1;71rESC(BESC[mESC[4lESC[?7hESC[39;49mESC]4;0;rgb:FF/00/00ESC\ESC]4;1;rgb:FF/00/00ESC\ESC]4;2;rgb:FF/00/00ESC\ESC]4;3;rgb:FF/00/00ESC\ESC]4;4;rgb:FF/00/00ESC\ESC]4;5;rgb:FF/00/00ESC\ESC]4;6;rgb:FF/00/00ESC\ESC]4;7;rgb:FF/00/00ESC\ESC]4;8;rgb:FF/00/00ESC\
ESC]4;9;rgb:FF/00/00ESC\ESC]4;10;rgb:FF/00/00ESC\ESC]4;11;rgb:FF/00/00ESC\ESC]4;12;rgb:FF/00/00ESC\ESC]4;13;rgb:FF/00/00ESC\ESC]4;14;rgb:FF/00/00ESC\ESC]4;15;rgb:FF/00/00ESC\ESC[39;49mESC[37mESC[40mESC[HESC[2J

ESC[39;49mESC[71dESC[KESC[39;49mESC]104^GESC[71;1HESC[?1049lESC[23;0;0t^MESC[?1lESC>

So on a regular Ubuntu Terminal the last line seems to properly reset the colors, for Windows Terminal and conhost.exe this does not seem to be the case. Someone familiar with those Escape sequences can probably understand the output, but for me it's just a lot of gibberish. (Also there's probably a way to transform this output into a bash script to skip the whole compilation step in the reproducer, no idea on how to do that though, also this makes it dependent on the os/terminal capabilities probably).
The reset command in bash does not help either

If there's some more info you need me to provide I'd be happy to help here.

Originally created by @RoiEXLab on GitHub (Jul 3, 2022). ### Windows Terminal version 1.14.145 (the latest Windows Store preview) ### Windows build number 10.0.19044.1766 ### Other Software ncurses (probably not necessary, but used for the reproducer) WSL using Ubuntu 20.04 ### Steps to reproduce You need to have a working C++ compiler and ncurses installed (`sudo apt install libncurses-dev`), also I'm using colortest (`sudo apt install colortest`) to illustrate the before and after differences. Run `colortest-256` in the terminal. This should produce an output similar to this: ![Color Example before](https://user-images.githubusercontent.com/8350879/177055326-9f0d2566-31b0-4bf0-89b3-de439bdb2319.png) Then you create this file called "MinimalExample.cpp" ```c++ #include <algorithm> #include <iostream> #include <ncurses.h> #include <unistd.h> int main() { initscr(); start_color(); for (int color = 0; color < std::min(16, COLORS); color++) { init_color(color, 1000, 0, 0); } refresh(); usleep(500000); // separates initialization from tear down in stdout std::cout << std::endl << std::endl; endwin(); } ``` And compile it using g++ (clang should work too in theory, haven't tested it) using `g++ ./MinimalExample.cpp -lncurses`. Then run it using `./a.out`. ### Expected Behavior Using a regular bash shell inside a Ubuntu 20.04 VM `colortest-256` has the same output regardless if the example code has been run. (This is also the case when using the VS Code Terminal with the WSL integration.) Within the application the colors 0-15 are correctly changing, it should just reset properly when ending the application. ### Actual Behavior Using the standard terminal (conhost.exe) and within Windows Terminal this causes the 16 standard colors to be replaced with `#F00`. This makes `colortest-256` output this result: ![Colortest output after](https://user-images.githubusercontent.com/8350879/177055431-308ec71a-96c2-41a8-af6d-c54c4cbc2623.png) When looking at stdout the example code creates something along those lines (the output is escaped to be readable): ``` ESC[?1049hESC[22;0;0tESC[1;71rESC(BESC[mESC[4lESC[?7hESC[39;49mESC]4;0;rgb:FF/00/00ESC\ESC]4;1;rgb:FF/00/00ESC\ESC]4;2;rgb:FF/00/00ESC\ESC]4;3;rgb:FF/00/00ESC\ESC]4;4;rgb:FF/00/00ESC\ESC]4;5;rgb:FF/00/00ESC\ESC]4;6;rgb:FF/00/00ESC\ESC]4;7;rgb:FF/00/00ESC\ESC]4;8;rgb:FF/00/00ESC\ ESC]4;9;rgb:FF/00/00ESC\ESC]4;10;rgb:FF/00/00ESC\ESC]4;11;rgb:FF/00/00ESC\ESC]4;12;rgb:FF/00/00ESC\ESC]4;13;rgb:FF/00/00ESC\ESC]4;14;rgb:FF/00/00ESC\ESC]4;15;rgb:FF/00/00ESC\ESC[39;49mESC[37mESC[40mESC[HESC[2J ESC[39;49mESC[71dESC[KESC[39;49mESC]104^GESC[71;1HESC[?1049lESC[23;0;0t^MESC[?1lESC> ``` So on a regular Ubuntu Terminal the last line seems to properly reset the colors, for Windows Terminal and conhost.exe this does not seem to be the case. Someone familiar with those Escape sequences can probably understand the output, but for me it's just a lot of gibberish. (Also there's probably a way to transform this output into a bash script to skip the whole compilation step in the reproducer, no idea on how to do that though, also this makes it dependent on the os/terminal capabilities probably). The `reset` command in bash does not help either If there's some more info you need me to provide I'd be happy to help here.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 05:56:19 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17850