WT should set COLORTERM #14987

Open
opened 2026-01-31 04:25:11 +00:00 by claunia · 49 comments
Owner

Originally created by @heaths on GitHub (Aug 26, 2021).

Description of the new feature/enhancement

Related to #1040, WT should set the COLORTERM environment variable to "truecolor" since WT does support truecolor. I can understand how changing TERM to "xterm-truecolor" (from "xterm-256color") could be a breaking change, but that's what COLORTERM is for.

Some tools like with cli/cli#4079 use this to determine if 24-bit colors should be emitted. Easy enough for users to define - either as Windows environment variables or update their shell profile e.g., .bashrc, but users who don't know what won't enjoy a wash of color by default like with gh issue list starting with v2.0.0.

Proposed technical implementation details (optional)

WT should ideally define the environment variable COLORTERM=truecolor within its own process environment block by default.

/cc @mislav

Originally created by @heaths on GitHub (Aug 26, 2021). # Description of the new feature/enhancement Related to #1040, WT should set the `COLORTERM` environment variable to "truecolor" since WT does support truecolor. I can understand how changing `TERM` to "xterm-truecolor" (from "xterm-256color") could be a breaking change, but that's what `COLORTERM` is for. Some tools like with cli/cli#4079 use this to determine if 24-bit colors should be emitted. Easy enough for users to define - either as Windows environment variables or update their shell profile e.g., _.bashrc_, but users who don't know what won't enjoy a wash of color by default like with `gh issue list` starting with v2.0.0. # Proposed technical implementation details (optional) WT should ideally define the environment variable `COLORTERM=truecolor` within its own process environment block by default. /cc @mislav
claunia added the Help WantedIssue-TaskProduct-TerminalArea-TerminalConnection labels 2026-01-31 04:25:11 +00:00
Author
Owner

@WSLUser commented on GitHub (Aug 30, 2021):

Related: https://github.com/microsoft/terminal/issues/8303. Might get duped into that one. Also related but was closed as something they're not willing to do as infocmp doesn't exist nor planned to exist: https://github.com/microsoft/terminal/issues/8336

@WSLUser commented on GitHub (Aug 30, 2021): Related: https://github.com/microsoft/terminal/issues/8303. Might get duped into that one. Also related but was closed as something they're not willing to do as `infocmp` doesn't exist nor planned to exist: https://github.com/microsoft/terminal/issues/8336
Author
Owner

@zadjii-msft commented on GitHub (Aug 30, 2021):

Discussed this with Dustin last week - I think we're both cool with this now. I think we were both more reluctant to do it in the past because it's just not a great solution, but it works for most people. So we may as well, same with TERM_PROGRAM and TERM_PROGRAM_VERSION. If people really want to take dependencies on these three, then why not?

@zadjii-msft commented on GitHub (Aug 30, 2021): Discussed this with Dustin last week - I think we're both cool with this now. I think we were both more reluctant to do it in the past because it's just not a _great_ solution, but it works for most people. So we may as well, same with `TERM_PROGRAM` and `TERM_PROGRAM_VERSION`. If people really want to take dependencies on these three, then _why not_?
Author
Owner

@heaths commented on GitHub (Aug 30, 2021):

@DHowett, @mislav for truecolor-detection support, is this really the right detection then? There's mention of many different TERM values that wouldn't match these checks. Seems TERM has become grossly overloaded and it's hard to glean anything consistent from it.

From a quick search for COLORTERM, it seems its usage is just as convoluted as TERM. Perhaps the only reliable way is to do something like this, which I've seen mentioned elsewhere.

@heaths commented on GitHub (Aug 30, 2021): @DHowett, @mislav for truecolor-detection support, is [this](https://github.com/cli/cli/blob/e6ff77ce73c201b0ee36d2b802ea45e9e1ad1822/pkg/iostreams/color.go#L36-L50) really the right detection then? There's mention of many different `TERM` values that wouldn't match these checks. Seems `TERM` has become grossly overloaded and it's hard to glean anything consistent from it. From a quick search for `COLORTERM`, it seems its usage is just as convoluted as `TERM`. Perhaps the only reliable way is to do something like [this](https://gist.github.com/XVilka/8346728#querying-the-terminal), which I've seen mentioned elsewhere.
Author
Owner

@zadjii-msft commented on GitHub (Aug 30, 2021):

Perhaps the only reliable way is to do something like this, which I've seen mentioned elsewhere.

Woah, I've never seen that particular sequence (\eP$qm\e) used before. I don't think we support it, so that definitely won't work right on Windows (conhost or Terminal). We also don't support the colon syntax for RGB colors currently, #4321. (aside: when did that version get so popular? I swear I only ever saw the semicolon version years ago when I first implemented RGB support).

You might be able to get away with just adding a if runtime.GOOS == "windows" if you can be relatively certain that the code is running on Windows 10. RGB support was added in RS2, so there's only 3 releases of Windows 10 that didn't support it (TH1, TH2, RS1), and even then VT support was only added in TH2 in the first place. Granted, I'm no golang user myself so if you need to be more precise than that, I won't be any help :P

@zadjii-msft commented on GitHub (Aug 30, 2021): > Perhaps the only reliable way is to do something like this, which I've seen mentioned elsewhere. Woah, I've never seen that particular sequence (`\eP$qm\e`) used before. I don't think we support it, so that _definitely_ won't work right on Windows (conhost or Terminal). We also don't support the colon syntax for RGB colors currently, #4321. (aside: when did that version get so popular? I swear I only ever saw the semicolon version years ago when I first implemented RGB support). You might be able to get away with just adding a `if runtime.GOOS == "windows"` if you can be relatively certain that the code is running on Windows 10. RGB support was added in RS2, so there's only 3 releases of Windows 10 that didn't support it (TH1, TH2, RS1), and even then VT support was only added in TH2 in the first place. Granted, I'm no golang user myself so if you need to be more precise than that, I won't be any help :P
Author
Owner

@WSLUser commented on GitHub (Aug 30, 2021):

https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences exists and notcurses is using it for the new experimental support of Windows. Notcurses in facts manipulates the terminfo entry to grab what it needs for the various terminals. There's no denying that terminfo isn't the greatest solution but no consensus appears to have been reached for implementing a standardized query method for terminals to use so any terminal that does have a query detection feature implements it in different ways, which does in the end rely on terminfo at some point.

(This all being said, WT is certainly able to create it's own query method that reflects that doc, but since there are other terminals on Windows to account for, the env vars would still be needed for them)

@WSLUser commented on GitHub (Aug 30, 2021): https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences exists and notcurses is using it for the new experimental support of Windows. Notcurses in facts manipulates the terminfo entry to grab what it needs for the various terminals. There's no denying that terminfo isn't the greatest solution but no consensus appears to have been reached for implementing a standardized query method for terminals to use so any terminal that does have a query detection feature implements it in different ways, which does in the end rely on terminfo at some point. (This all being said, WT is certainly able to create it's own query method that reflects that doc, but since there are other terminals on Windows to account for, the env vars would still be needed for them)
Author
Owner

@heaths commented on GitHub (Aug 30, 2021):

With that in mind, it really seems like there's no good solution since the CLI supports pre-Windows 10 as do many apps out there.

So would just trying to emit an RGB VT sequence be best? If a terminal doesn't support it, it should just ignore the sequence and emit text with the default background and foreground colors, right? So there's really no point in trying to detect if truecolor is supported?

/cc @mislav

@heaths commented on GitHub (Aug 30, 2021): With [that](https://github.com/microsoft/terminal/issues/11057#issuecomment-908496636) in mind, it really seems like there's no good solution since the CLI supports pre-Windows 10 as do many apps out there. So would just trying to emit an RGB VT sequence be best? If a terminal doesn't support it, it *should* just ignore the sequence and emit text with the default background and foreground colors, right? So there's really no point in trying to detect if truecolor is supported? /cc @mislav
Author
Owner

@mislav commented on GitHub (Aug 30, 2021):

If a terminal doesn't support it, it should just ignore the sequence and emit text with the default background and foreground colors, right?

It should but doesn't always. Terminal.app does not support RGB colors and yet outputs strange formatting when you try to use RGB sequences. As long as the default terminal emulator on one of major operating systems can't get this right, authors of CLI apps such as myself will rather want to operate on detection rather than blind faith. Plus, we might want to output 256-color to clients that do not support truecolor, rather than outputting truecolor and have it be rendered with default foreground+background.

for truecolor-detection support, is this really the right detection then?

I don't know! That's the best (read: easiest, most straightforward) that I saw various CLI tools come up with.

@mislav commented on GitHub (Aug 30, 2021): > If a terminal doesn't support it, it _should_ just ignore the sequence and emit text with the default background and foreground colors, right? It should but doesn't always. Terminal.app does not support RGB colors and yet outputs strange formatting when you try to use RGB sequences. As long as the default terminal emulator on one of major operating systems can't get this right, authors of CLI apps such as myself will rather want to operate on detection rather than blind faith. Plus, we might want to output 256-color to clients that do not support truecolor, rather than outputting truecolor and have it be rendered with default foreground+background. > for truecolor-detection support, is [this](https://github.com/cli/cli/blob/e6ff77ce73c201b0ee36d2b802ea45e9e1ad1822/pkg/iostreams/color.go#L36-L50) really the right detection then? I don't know! That's the best (read: easiest, most straightforward) that I saw various CLI tools come up with.
Author
Owner

@heaths commented on GitHub (Aug 30, 2021):

As long as the default terminal emulator on one of major operating systems can't get this right, authors of CLI apps such as myself will rather want to operate on detection rather than blind faith.

Totally makes sense and I agree. It's just strange that, at least when it comes to colors/VT support, writing console apps seems to be harder/more involved than writing windowed apps. 🙄

Still, the crux of this bug: if COLORTERM is meant to detect color support - though what the value is set to doesn't seem well-defined - perhaps the more oft-supported TERM=xterm-256color is appropriate here for WT while COLORTERM=xterm-truecolor is appropriate in addition. TERM seems to be more general-purpose from various reads, while COLORTERM seems to be more specific to color support, as the name also implies.

@heaths commented on GitHub (Aug 30, 2021): > As long as the default terminal emulator on one of major operating systems can't get this right, authors of CLI apps such as myself will rather want to operate on detection rather than blind faith. Totally makes sense and I agree. It's just strange that, at least when it comes to colors/VT support, writing console apps seems to be harder/more involved than writing windowed apps. 🙄 Still, the crux of this bug: if `COLORTERM` is meant to detect color support - though what the value is set to doesn't seem well-defined - perhaps the more oft-supported `TERM=xterm-256color` is appropriate here for WT while `COLORTERM=xterm-truecolor` is appropriate in addition. `TERM` seems to be more general-purpose from various reads, while `COLORTERM` seems to be more specific to color support, as the name also implies.
Author
Owner

@j4james commented on GitHub (Aug 31, 2021):

Woah, I've never seen that particular sequence (\eP$qm\e) used before.

I'm sure I have mentioned this before somewhere, but I'm convinced that just supporting DECRQSS and DECRQM would solve 99% of feature detection issues. Admittedly it's not always that straightforward to use, and I know a lot of people don't like terminal queries in general, but they're at least an existing standard that has a reasonable level of support amongst other terminals.

I actually have a partial DECRQSS implementation in a stash somewhere which might be worth resurrecting. I think I put it on hold because we didn't have the APIs in place to query all the settings that were needed, but maybe a partial implementation is still better than nothing.

That said, I am also in favor of a COLORTERM env, just because it's quite widely used, and I don't see any harm in it. I'm not so sure about TERM_PROGRAM, though, because that encourages apps to do the same stupid things that web developers did with user-agent strings, like writing code that refuses to run if the detected terminal isn't one that they recognise (this is not just hypothetical - I've seen it happening already).

@j4james commented on GitHub (Aug 31, 2021): > Woah, I've never seen that particular sequence (`\eP$qm\e`) used before. I'm sure I have mentioned this before somewhere, but I'm convinced that just supporting `DECRQSS` and `DECRQM` would solve 99% of feature detection issues. Admittedly it's not always that straightforward to use, and I know a lot of people don't like terminal queries in general, but they're at least an existing standard that has a reasonable level of support amongst other terminals. I actually have a partial `DECRQSS` implementation in a stash somewhere which might be worth resurrecting. I think I put it on hold because we didn't have the APIs in place to query all the settings that were needed, but maybe a partial implementation is still better than nothing. That said, I am also in favor of a `COLORTERM` env, just because it's quite widely used, and I don't see any harm in it. I'm not so sure about `TERM_PROGRAM`, though, because that encourages apps to do the same stupid things that web developers did with user-agent strings, like writing code that refuses to run if the detected terminal isn't one that they recognise (this is not just hypothetical - I've seen it happening already).
Author
Owner

@DHowett commented on GitHub (Aug 31, 2021):

I'm not so sure about TERM_PROGRAM, though, because that encourages apps to do the same stupid things that web developers did with user-agent strings, like writing code that refuses to run if the detected terminal isn't one that they recognise (this is not just hypothetical - I've seen it happening already).

I felt like this for a while, but then I realized that we're fighting a losing battle against people who are looking for WT_SESSION or checking the process tree for WindowsTerminal.exe and lighting up features that would otherwise work fine in conhost only when they find it. For all the issues TERM_PROGRAM has, I suspect that it is only as bad as what folks are already doing. I don't know.

@DHowett commented on GitHub (Aug 31, 2021): > I'm not so sure about `TERM_PROGRAM`, though, because that encourages apps to do the same stupid things that web developers did with user-agent strings, like writing code that refuses to run if the detected terminal isn't one that they recognise (this is not just hypothetical - I've seen it happening already). I felt like this for a while, but then I realized that we're fighting a losing battle against people who are looking for `WT_SESSION` or checking the process tree for `WindowsTerminal.exe` and lighting up features that _would otherwise work fine in conhost_ only when they find it. For all the issues `TERM_PROGRAM` has, I suspect that it is only as bad as what folks are already doing. I don't know.
Author
Owner

@heaths commented on GitHub (Aug 31, 2021):

TERM_PROGRAM would create the mess browsers had (have, really) for decades with UAs. Feature-level detection would be ideal, and without queuing up xkcd's strip on standards, TERM=xterm-256color seems pretty standard across most terminals while COLORTERM seems to be akin to a "v2" for TERM. The bigger question is what it should be set to. In some discussions, it seems having it set to anything at all should indicate at least 256 color support if not truecolor support.

If you'd set TERM_PROGRAM=WindowsTerminal or something like that, as a dev I'd still be tempted to use WT_SESSION because it's been around longer and supports more customers.

@heaths commented on GitHub (Aug 31, 2021): `TERM_PROGRAM` would create the mess browsers had (have, really) for decades with UAs. Feature-level detection would be ideal, and without queuing up xkcd's strip on standards, `TERM=xterm-256color` seems pretty standard across most terminals while `COLORTERM` seems to be akin to a "v2" for `TERM`. The bigger question is what it should be set to. In some discussions, it seems having it set to anything at all should indicate at least 256 color support if not truecolor support. If you'd set `TERM_PROGRAM=WindowsTerminal` or something like that, as a dev I'd still be tempted to use `WT_SESSION` because it's been around longer and supports more customers.
Author
Owner

@Diablo-D3 commented on GitHub (Oct 13, 2021):

Side note for those who are following this ticket: https://github.com//termstandard/colors is the best documentation out there for what supports COLORTERM. Windows Terminal is already on this list, even though it isn't emitting the variable yet.

@Diablo-D3 commented on GitHub (Oct 13, 2021): Side note for those who are following this ticket: https://github.com//termstandard/colors is the best documentation out there for what supports COLORTERM. Windows Terminal is already on this list, even though it isn't emitting the variable yet.
Author
Owner

@PennRobotics commented on GitHub (Jan 11, 2022):

oh-my-zsh changed their update script to use truecolor if supported. I had replaced the omz ASCII art and color definitions, so having to merge this linked commit made me realize $TERM is xterm-256color and $COLORTERM is undefined in Windows Terminal.

Until this issue changes (subscribe for issue updates) the update script will detect full color and choose the right palette after adding export COLORTERM=truecolor near the top of .zshrc

The new oh-my-zsh commit uses the XVilke gist that @heaths linked—although not the query method—so any other script using the variable check from this gist should also get support after defining COLORTERM. I imagine one could simply add this in .bashrc as well (or whichever dotfile is shell-relevant).

@PennRobotics commented on GitHub (Jan 11, 2022): [oh-my-zsh changed their update script to use truecolor if supported](https://github.com/ohmyzsh/ohmyzsh/commit/fbdc078fa60c2c34a7f5078846902538d162fbee#diff-4b98dbe69610bd8f3e7440e55255e2fd22da4659b509cefbe976c3e03d6458e0). I had replaced the omz ASCII art and color definitions, so having to merge this linked commit made me realize $TERM is xterm-256color and $COLORTERM is undefined in Windows Terminal. Until this issue changes (subscribe for issue updates) the update script will detect full color and choose the right palette after **adding `export COLORTERM=truecolor` near the top of .zshrc** The new oh-my-zsh commit uses the [XVilke gist](https://github.com/microsoft/terminal/issues/11057#issuecomment-908481176) that @heaths linked—although not the query method—so any other script using the variable check from this gist should also get support after defining COLORTERM. I imagine one could simply add this in .bashrc as well (or whichever dotfile is shell-relevant).
Author
Owner

@j4james commented on GitHub (Jan 11, 2022):

Just FYI, that COLORTERM test in oh-my-zsh is essentially useless, because any terminal that doesn't support the RGB color sequences is also not likely to support the fallback 256-color sequences. They'll potentially just end up with a bunch of blinking text as a result of the 5 in the SGR. It's possible they just don't care about supporting older terminals, but then they might as well use the RGB colors for everyone and not bother with the COLORTERM test.

@j4james commented on GitHub (Jan 11, 2022): Just FYI, that `COLORTERM` test in oh-my-zsh is essentially useless, because any terminal that doesn't support the RGB color sequences is also not likely to support the fallback 256-color sequences. They'll potentially just end up with a bunch of blinking text as a result of the 5 in the SGR. It's possible they just don't care about supporting older terminals, but then they might as well use the RGB colors for everyone and not bother with the `COLORTERM` test.
Author
Owner

@jredfox commented on GitHub (Jun 10, 2022):

ok after looking $COLORTERM is to be the only color. if it's the same name as $TERM then that's a bug on the terminal. tested on linux terminals some do contain the bug others do not but it wouldn't make sense why $COLORTERM would be equal to $TERM

@jredfox commented on GitHub (Jun 10, 2022): ok after looking `$COLORTERM` is to be the only color. if it's the same name as `$TERM` then that's a bug on the terminal. tested on linux terminals some do contain the bug others do not but it wouldn't make sense why `$COLORTERM` would be equal to `$TERM`
Author
Owner

@Diablo-D3 commented on GitHub (Jun 10, 2022):

COLORTERM only has one meaningful value: truecolor. If a terminal isn't true color, the variable should remain unset.

@Diablo-D3 commented on GitHub (Jun 10, 2022): `COLORTERM` only has one meaningful value: `truecolor`. If a terminal isn't true color, the variable should remain unset.
Author
Owner

@jredfox commented on GitHub (Jun 10, 2022):

No I seen lots of Linux terminals that return xterm-256 from that variable. If it’s unset that means it’s an older terminal then you should also look for $TERM but $TERM a lot of times gets set to an older color value such as xterm not 256 and xterm-256 even if it supports true color that value will remain non true color regardless.

Example easily produced. gnome-terminal latest linux mint distro. print $TERM and $COLORTERM it will give you xterm-256color or was it xterm-256, fallowed by truecolor

@jredfox commented on GitHub (Jun 10, 2022): No I seen lots of Linux terminals that return xterm-256 from that variable. If it’s unset that means it’s an older terminal then you should also look for $TERM but $TERM a lot of times gets set to an older color value such as xterm not 256 and xterm-256 even if it supports true color that value will remain non true color regardless. Example easily produced. `gnome-terminal` latest linux mint distro. print `$TERM` and `$COLORTERM` it will give you xterm-256color or was it xterm-256, fallowed by truecolor
Author
Owner

@Diablo-D3 commented on GitHub (Jun 11, 2022):

TERM should return xterm-256color if it is a modern term that chooses to implement xterm as-is; gnome-terminal uses libvte, and libvte-based terminals, as far as I know, do not implement COLORTERM incorrectly. What you are describing sounds like a bug with gnome-terminal if you are accurately describing it.

Software out there that implements truecolor either check if COLORTERM contains truecolor and/or 24bit, or in some cases, is simply set at all. I have not seen one that checks for equals exactly 'truecolor', which allows what I think you described to work (COLORTERM=xterm-truecolor).

@Diablo-D3 commented on GitHub (Jun 11, 2022): `TERM` should return xterm-256color if it is a modern term that chooses to implement xterm as-is; `gnome-terminal` uses `libvte`, and `libvte`-based terminals, as far as I know, do not implement `COLORTERM` incorrectly. What you are describing sounds like a bug with `gnome-terminal` if you are accurately describing it. Software out there that implements truecolor either check if `COLORTERM` contains `truecolor` and/or `24bit`, or in some cases, is simply set at all. I have not seen one that checks for equals exactly 'truecolor', which allows what I think you described to work (`COLORTERM=xterm-truecolor`).
Author
Owner

@eggbean commented on GitHub (Sep 19, 2022):

Is there a way to make Windows Terminal set $COLORTERM in the settings file? If not, how can I make a bash conditional statement to determine if the terminal is Windows Terminal so I can set it in ~/.bash_profile?

@eggbean commented on GitHub (Sep 19, 2022): Is there a way to make Windows Terminal set `$COLORTERM` in the settings file? If not, how can I make a bash conditional statement to determine if the terminal is Windows Terminal so I can set it in `~/.bash_profile`?
Author
Owner

@heaths commented on GitHub (Sep 19, 2022):

Is there a way to make Windows Terminal set $COLORTERM in the settings file? If not, how can I make a bash conditional statement to determine if the terminal is Windows Terminal so I can set it in ~/.bash_profile?

@eggbean you can check for $WT_SESSION - if it's defined at all - and conditionally set $COLORTERM. But, yeah, I agree: it'd be nice if WT just did this automatically.

@heaths commented on GitHub (Sep 19, 2022): > Is there a way to make Windows Terminal set `$COLORTERM` in the settings file? If not, how can I make a bash conditional statement to determine if the terminal is Windows Terminal so I can set it in `~/.bash_profile`? @eggbean you can check for `$WT_SESSION` - if it's defined at all - and conditionally set `$COLORTERM`. But, yeah, I agree: it'd be nice if WT just did this automatically.
Author
Owner

@eggbean commented on GitHub (Sep 19, 2022):

@heaths Thanks.

@eggbean commented on GitHub (Sep 19, 2022): @heaths Thanks.
Author
Owner

@jredfox commented on GitHub (Oct 11, 2022):

Nah tested on 40 Linux terminals colorterm not being set doesn't mean it's going to be true color

@jredfox commented on GitHub (Oct 11, 2022): Nah tested on 40 Linux terminals colorterm not being set doesn't mean it's going to be true color
Author
Owner

@mikehearn commented on GitHub (Apr 1, 2023):

Unfortunately $WT_SESSION turns out to not be reliable (sigh). Here's a funny trick:

  • Open Explorer
  • Right click on a folder whilst holding the shift key
  • Select "Show more options"
  • click "open powershell window here"
  • Observe that although what you get is Windows Terminal, WT_SESSION does not exist in the environment.

Why not? I have no idea and don't wish to spend time finding out.

Please please please just implement TERM_PROGRAM and other user agent strings. Yes, feature detection, I know. It's a lovely idea but it will never be enough by itself. In our case we're trying to detect WT specifically because there are bugs in the old legacy terminal, maybe in old versions of Windows I don't know, for example setting the console to UTF-8 will change the font in every single legacy console window. That annoys people who for whatever reason prefer to use that vs the new WT (they exist, I've worked with them) and so we just say oh whatever, if you use old stuff you get old stuff. That's why we want to detect WT, it's more like a negative detection and thus feature detection won't ever work because old conhost will gamely advertise that it has these features and then do the wrong thing.

Yep, it does create other problems. Non-WT terminals that use the same codepaths, for example. Fine, a problem for another day. They can advertise themselves as "Windows Terminal/5 (compatible; FooTerm)" and that's OK.

@mikehearn commented on GitHub (Apr 1, 2023): Unfortunately `$WT_SESSION` turns out to not be reliable (sigh). Here's a funny trick: * Open Explorer * Right click on a folder _whilst holding the shift key_ * Select "Show more options" * click "open powershell window here" * Observe that although what you get is Windows Terminal, `WT_SESSION` does not exist in the environment. Why not? I have no idea and don't wish to spend time finding out. Please please please just implement TERM_PROGRAM and other user agent strings. Yes, feature detection, I know. It's a lovely idea but it will never be enough by itself. In our case we're trying to detect WT specifically because there are bugs in the old legacy terminal, maybe in old versions of Windows I don't know, for example setting the console to UTF-8 will change the font in every single legacy console window. That annoys people who for whatever reason prefer to use that vs the new WT (they exist, I've worked with them) and so we just say oh whatever, if you use old stuff you get old stuff. That's why we want to detect WT, it's more like a negative detection and thus feature detection won't ever work because old conhost will gamely advertise that it has these features and then do the wrong thing. Yep, it does create other problems. Non-WT terminals that use the same codepaths, for example. Fine, a problem for another day. They can advertise themselves as "Windows Terminal/5 (compatible; FooTerm)" and that's OK.
Author
Owner

@zadjii-msft commented on GitHub (Apr 3, 2023):

@mikehearn what you're seeing there is #13006 and is a Hard problem - in that scenario, powershell.exe was launched outside of the Terminal, then later attached to it. WT was not involved in launching it at all, so it had no opportunity to add any environment variables. Not even conhost would have a chance to say "I'm conhost, NOT Terminal" here!

@zadjii-msft commented on GitHub (Apr 3, 2023): @mikehearn what you're seeing there is #13006 and is a **H**ard problem - in that scenario, `powershell.exe` was launched outside of the Terminal, then later attached to it. WT was not involved in launching it _at all_, so it had no opportunity to add _any_ environment variables. Not even conhost would have a chance to say "I'm conhost, NOT Terminal" here!
Author
Owner

@mikehearn commented on GitHub (Apr 3, 2023):

Huh, OK, that's an interesting problem indeed. I guess ANSI escapes to do feature detection and/or getting a user-agent equivalent would be the only way forward there.

@mikehearn commented on GitHub (Apr 3, 2023): Huh, OK, that's an interesting problem indeed. I guess ANSI escapes to do feature detection and/or getting a user-agent equivalent would be the only way forward there.
Author
Owner

@heaths commented on GitHub (Apr 3, 2023):

Much of this issue has talked about corner cases where setting TERM=xterm-256 and COLORTERM=truecolor may not be 100% accurate, but as has come up many times, it seems no terminal is perfect. Yet, the computing world carries on. Terminal programs are being run in mind-boggling numbers every minute of every day, and the overall experience is still fine. Sometimes those programs will add workarounds themselves to odd but significant enough problems.

Is it really worth not setting the variables as describe above in spite of all the programs that would work just fine? Feature detection based on ANSI sequences is burdensome for every program to implement when a couple of env vars are much easier to check and correct in the vast majority of cases. And feature detection via ANSI escape sequences don't give you the full picture anyway. Just because it reports truecolor doesn't mean it supports hyperlinks. And it's been discussed how different terminals respond to : or ; separators while some support either. It's already a grab bag of different behaviors. Why make it harder?

@heaths commented on GitHub (Apr 3, 2023): Much of this issue has talked about corner cases where setting `TERM=xterm-256` and `COLORTERM=truecolor` may not be 100% accurate, but as has come up many times, it seems no terminal is perfect. Yet, the computing world carries on. Terminal programs are being run in mind-boggling numbers every minute of every day, and the overall experience is still fine. Sometimes those programs will add workarounds themselves to odd but significant enough problems. Is it really worth not setting the variables as describe above in spite of all the programs that would work just fine? Feature detection based on ANSI sequences is burdensome for *every* program to implement when a couple of env vars are much easier to check and correct in the vast majority of cases. And feature detection via ANSI escape sequences don't give you the full picture anyway. Just because it reports truecolor doesn't mean it supports hyperlinks. And it's been discussed how different terminals respond to `:` or `;` separators while some support either. It's already a grab bag of different behaviors. Why make it harder?
Author
Owner

@CannibalVox commented on GitHub (Nov 16, 2024):

What is the actual status of this ticket? I see earlier in the ticket that there was some resistence to using $COLORTERM, but then broadly there seems to be support, even from maintainers, throughout the rest of the ticket. The ticket is tagged with "Help Wanted". Is this ticket really waiting for someone to come along and add a single environment variable in a PR?

@CannibalVox commented on GitHub (Nov 16, 2024): What is the actual status of this ticket? I see earlier in the ticket that there was some resistence to using $COLORTERM, but then broadly there seems to be support, even from maintainers, throughout the rest of the ticket. The ticket is tagged with "Help Wanted". Is this ticket really waiting for someone to come along and add a single environment variable in a PR?
Author
Owner

@AnalogFeelings commented on GitHub (Dec 17, 2024):

Lack of COLORTERM makes onefetch fall back to 16 color mode, is this going to be fixed any time soon?

@AnalogFeelings commented on GitHub (Dec 17, 2024): Lack of `COLORTERM` makes [onefetch](https://github.com/o2sh/onefetch/tree/main) fall back to 16 color mode, is this going to be fixed any time soon?
Author
Owner

@ldemailly commented on GitHub (Apr 26, 2025):

what is the mechanism to easily detect that windows terminal does support truecolor (it does) - ideally through env.
I'm not seeing anything in dir env: actually (on windows powershell before starting my program), TERM is there in bash though but set wrong (xterm-256) without COLORTERM

@ldemailly commented on GitHub (Apr 26, 2025): what is the mechanism to easily detect that windows terminal does support truecolor (it does) - ideally through env. I'm not seeing anything in `dir env:` actually (on windows powershell before starting my program), TERM is there in bash though but set wrong (xterm-256) without COLORTERM
Author
Owner

@heaths commented on GitHub (Apr 28, 2025):

With environment variables there really isn't, hence the ask. You have to write code to either call Windows-specific APIs or to write a VT sequence to the terminal and check the response. Neither is ideal, hence this feature request.

@heaths commented on GitHub (Apr 28, 2025): With environment variables there really isn't, hence the ask. You have to write code to either [call Windows-specific APIs](https://docs.microsoft.com/windows/console/console-virtual-terminal-sequences) or to write a VT sequence to the terminal and check the response. Neither is ideal, hence this feature request.
Author
Owner

@j4james commented on GitHub (Apr 28, 2025):

Well now that Windows Terminal supports the colon version of the ITU format, you can always just use that with a fallback to ANSI colors, e.g. something like this:

printf "\e[33;44m\e[38:2::255:187:114;48:2::65:114:226m TEST \e[m\n"

On the Window 10 console, and older versions of Windows Terminal, that'll give you the ANSI colors.

Image

And on more recent versions of Windows Terminal you'll get the 24-bit colors.

Image

There'll probably be terminals where that doesn't work correctly, so you might get no colors at all, or some form of messed up attributes, but that's their bug to fix.

@j4james commented on GitHub (Apr 28, 2025): Well now that Windows Terminal supports the colon version of the ITU format, you can always just use that with a fallback to ANSI colors, e.g. something like this: ```bash printf "\e[33;44m\e[38:2::255:187:114;48:2::65:114:226m TEST \e[m\n" ``` On the Window 10 console, and older versions of Windows Terminal, that'll give you the ANSI colors. ![Image](https://github.com/user-attachments/assets/2723b3e8-89a8-483a-8262-3889b08ac271) And on more recent versions of Windows Terminal you'll get the 24-bit colors. ![Image](https://github.com/user-attachments/assets/bcb70ade-cfe9-470b-a66a-1e0a7a3728ac) There'll probably be terminals where that doesn't work correctly, so you might get no colors at all, or some form of messed up attributes, but that's their bug to fix.
Author
Owner

@heaths commented on GitHub (Apr 29, 2025):

@j4james while that is good news, it doesn't fix the hundreds or thousands of apps/scripts out there that rely on COLORTERM already. Expecting everyone to update to support Windows - when most of those were already born out of linux and/or macOS (NextOS) - doesn't seem as feasible as defining COLORTERM appropriately.

@heaths commented on GitHub (Apr 29, 2025): @j4james while that is good news, it doesn't fix the hundreds or thousands of apps/scripts out there that rely on `COLORTERM` already. Expecting everyone to update to support Windows - when most of those were already born out of linux and/or macOS (NextOS) - doesn't seem as feasible as defining `COLORTERM` appropriately.
Author
Owner

@ldemailly commented on GitHub (Apr 29, 2025):

Also note that for performance critical TUIs (I know I know yet... that's what I do) sending both sets of color isn't really an option, that would bloat the data sent too much so I need to know if it's truecolor or not, I think I will do something ugly like if I am running on Windows, assume it's truecolor irrespective of TERM (I don't plan on supporting older non true color windows terminal, plus the end user could downgrade if needed, I'm just trying to have the default the most likely correct one)

@ldemailly commented on GitHub (Apr 29, 2025): Also note that for performance critical TUIs (I know I know yet... that's what I do) sending both sets of color isn't really an option, that would bloat the data sent too much so I need to know if it's truecolor or not, I think I will do something ugly like if I am running on Windows, assume it's truecolor irrespective of TERM (I don't plan on supporting older non true color windows terminal, plus the end user could downgrade if needed, I'm just trying to have the default the most likely correct one)
Author
Owner

@heaths commented on GitHub (Apr 29, 2025):

I think I will do something ugly like if I am running on Windows, assume it's truecolor irrespective of TERM

Given the support matrix, this is probably safe these days - especially among the dev community; however, I just wanted to point out this feature was mainly about fixing not only ever future app that is cross-plat, but all those that already exist and check TERM and/or COLORTERM. I wouldn't expect all those to "fix" themselves just for Windows. It's already bad enough across numerous ecosystems that many maintainers even today have no idea Windows has - for a sufficiently long time now - supported VT sequences. So many comments in various code bases I see, like, "Windows doesn't support ANSI color / PTY, so do nothing here."

Let's meet developers where they already are as much as possible, IMO. Setting COLORTERM=truecolor seems like a fairly easy, innocuous win.

@heaths commented on GitHub (Apr 29, 2025): > I think I will do something ugly like if I am running on Windows, assume it's truecolor irrespective of TERM Given the support matrix, this is probably safe these days - especially among the dev community; however, I just wanted to point out this feature was mainly about fixing not only ever future app that is cross-plat, but all those that already exist and check `TERM` and/or `COLORTERM`. I wouldn't expect all those to "fix" themselves just for Windows. It's already bad enough across numerous ecosystems that many maintainers even today have no idea Windows has - for a sufficiently long time now - supported VT sequences. So many comments in various code bases I see, like, "Windows doesn't support ANSI color / PTY, so do nothing here." Let's meet developers where they already are as much as possible, IMO. Setting `COLORTERM=truecolor` seems like a fairly easy, innocuous win.
Author
Owner

@ldemailly commented on GitHub (Apr 29, 2025):

Totally agree that would be best, I was just saying what I may personally do in the meanwhile. I also thought I understood that terminal doesn’t actually control the environment for say powershell which makes it not possible to just set COLORTERM (without some magic handshake?)

@ldemailly commented on GitHub (Apr 29, 2025): Totally agree that would be best, I was just saying what I may personally do in the meanwhile. I also thought I understood that terminal doesn’t actually control the environment for say powershell which makes it not possible to just set COLORTERM (without some magic handshake?)
Author
Owner

@j4james commented on GitHub (Apr 29, 2025):

I also thought I understood that terminal doesn’t actually control the environment

Yeah, this was explained earlier in the thread. I was actually somewhat in favor of COLORTERM at one point, until I tried adding it to Windows Terminal and found it didn't actually work half the time. It would just be a never ending source of bug reports.

@j4james commented on GitHub (Apr 29, 2025): > I also thought I understood that terminal doesn’t actually control the environment Yeah, this was explained earlier in the thread. I was actually somewhat in favor of `COLORTERM` at one point, until I tried adding it to Windows Terminal and found it didn't actually work half the time. It would just be a never ending source of bug reports.
Author
Owner

@Kazmirchuk commented on GitHub (Apr 29, 2025):

FWIW I've just added SetEnv COLORTERM=truecolor in my .ssh/config, I guess this is easy enough (+ACCEPT_ENV in sshd config on the server). However, many people might not even know about existence and meaning of $COLORTERM, so it would be nice to mention it in the official docs. Some chapter like "Tips to get the best out of your Windows Terminal experience"

@Kazmirchuk commented on GitHub (Apr 29, 2025): FWIW I've just added `SetEnv COLORTERM=truecolor` in my `.ssh/config`, I guess this is easy enough (+ACCEPT_ENV in sshd config on the server). However, many people might not even know about existence and meaning of $COLORTERM, so it would be nice to mention it in the official docs. Some chapter like "Tips to get the best out of your Windows Terminal experience"
Author
Owner

@heaths commented on GitHub (Apr 29, 2025):

terminal doesn’t actually control the environment

No, but most programs inherit their parent's environment block. powershell.exe and pwsh.exe both do. Set an env var, start a new shell within it, and you'll see the env var set therein.

@heaths commented on GitHub (Apr 29, 2025): > terminal doesn’t actually control the environment No, but most programs inherit their parent's environment block. powershell.exe and pwsh.exe both do. Set an env var, start a new shell within it, and you'll see the env var set therein.
Author
Owner

@ldemailly commented on GitHub (Apr 29, 2025):

I'm aware usually [always on unixes] programs (shell or otherwise) are launched by the terminal emulator as a parent or grand parent but I was referring to

in that scenario, powershell.exe was launched outside of the Terminal, then later attached to it. WT was not involved in launching it at all, so it had no opportunity to add any environment variables.

which is why I mentioned

without some magic handshake?

@ldemailly commented on GitHub (Apr 29, 2025): I'm aware usually [always on unixes] programs (shell or otherwise) are launched by the terminal emulator as a parent or grand parent but I was referring to > in that scenario, powershell.exe was launched outside of the Terminal, then later attached to it. WT was not involved in launching it at all, so it had no opportunity to add any environment variables. which is why I mentioned > without some magic handshake?
Author
Owner

@j4james commented on GitHub (Apr 29, 2025):

most programs inherit their parent's environment block. powershell.exe and pwsh.exe both do.

But Windows Terminal is often not the parent. 90% of the time that I'm using a terminal, I'll be launching cmd or bash or some other console app from the start menu, or from a folder in Windows Explorer. Windows Terminal has no say in what environment variables get set in that case.

without some magic handshake?

If you know of a magic incantation that will inject environment variables into an already running process, feel free to submit a PR that fixes this issue, or at least share the information so someone else can do it.

@j4james commented on GitHub (Apr 29, 2025): > most programs inherit their parent's environment block. powershell.exe and pwsh.exe both do. But Windows Terminal is often not the parent. 90% of the time that I'm using a terminal, I'll be launching `cmd` or `bash` or some other console app from the start menu, or from a folder in Windows Explorer. Windows Terminal has no say in what environment variables get set in that case. > without some magic handshake? If you know of a magic incantation that will inject environment variables into an already running process, feel free to submit a PR that fixes this issue, or at least share the information so someone else can do it.
Author
Owner

@heaths commented on GitHub (Apr 30, 2025):

But Windows Terminal is often not the parent.

Fair point. Personally, I just live inside the terminal but I appreciate not everyone does. But that makes me wonder: should conhost/conpty actually set COLORTERM then?

@heaths commented on GitHub (Apr 30, 2025): > But Windows Terminal is often not the parent. Fair point. Personally, I just live inside the terminal but I appreciate not everyone does. But that makes me wonder: should conhost/conpty actually set `COLORTERM` then?
Author
Owner

@ldemailly commented on GitHub (May 1, 2025):

If you know of a magic incantation that will inject environment variables into an already running process, feel free to submit a PR that fixes this issue, or at least share the information so someone else can do it.

I'm sure both being microsoft and one attaching magically to the other, there must be some handshake possible, api, message sending, something (to tell powershell it's running inside a COLORTERM)

@ldemailly commented on GitHub (May 1, 2025): > If you know of a magic incantation that will inject environment variables into an already running process, feel free to submit a PR that fixes this issue, or at least share the information so someone else can do it. I'm sure both being microsoft and one attaching magically to the other, there must be some handshake possible, api, message sending, something (to tell powershell it's running inside a COLORTERM)
Author
Owner

@heaths commented on GitHub (May 1, 2025):

to tell powershell it's running inside a COLORTERM

Except we're not just talking about powershell/pwsh here. All shells. I spend most of my time in bash inside WT.

@heaths commented on GitHub (May 1, 2025): > to tell powershell it's running inside a COLORTERM Except we're not just talking about powershell/pwsh here. All shells. I spend most of my time in bash inside WT.
Author
Owner

@ldemailly commented on GitHub (May 1, 2025):

yes so whichever mechanism that attaches a shell to WT without "starting" from inside WT (and for the ones starting inside, like I assume new tabs etc... sure WT can just directly set COLORTERM first)

@ldemailly commented on GitHub (May 1, 2025): yes so whichever mechanism that attaches a shell to WT without "starting" from inside WT (and for the ones starting inside, like I assume new tabs etc... sure WT can just directly set COLORTERM first)
Author
Owner

@j4james commented on GitHub (May 1, 2025):

The starting application is literally any EXE with a CUI subsystem. If you want COLORTERM set reliably on Windows, the place to do so is in the system environment dialog, and I suspect that anyone that actually cares about COLORTERM would have set that by now. The remainder are probably quite happy with standard ANSI colors that respect their color scheme.

@j4james commented on GitHub (May 1, 2025): The starting application is literally any EXE with a CUI subsystem. If you want COLORTERM set reliably on Windows, the place to do so is in the system environment dialog, and I suspect that anyone that actually cares about COLORTERM would have set that by now. The remainder are probably quite happy with standard ANSI colors that respect their color scheme.
Author
Owner

@schlich commented on GitHub (Sep 12, 2025):

anyone that actually cares about COLORTERM would have set that by now.

Yeah... no. What? I'm trying to understand your thought process but I thought this was quite dismissive. I'm a everyday WT user with Nushell as my daily driver and I had no idea why i wasn't getting full color support in helix until finding this thread, and I NEVER would have found this thread if it weren't for a decent error message when trying to set a helix theme.

Setting COLORTERM to "truecolor" worked brilliantly.

Try to consider others a bit more, not everyone is a genius like you

@schlich commented on GitHub (Sep 12, 2025): > anyone that actually cares about COLORTERM would have set that by now. Yeah... no. What? I'm trying to understand your thought process but I thought this was quite dismissive. I'm a everyday WT user with Nushell as my daily driver and I had no idea why i wasn't getting full color support in helix until finding this thread, and I NEVER would have found this thread if it weren't for a decent error message when trying to set a helix theme. Setting COLORTERM to "truecolor" worked brilliantly. Try to consider others a bit more, not everyone is a genius like you
Author
Owner

@schlich commented on GitHub (Sep 12, 2025):

Also, just for additional context, I spawn a nushell session by default by using the "default command" setting in WT. Hasn't caused any issues until now AFAIK

@schlich commented on GitHub (Sep 12, 2025): Also, just for additional context, I spawn a nushell session by default by using the "default command" setting in WT. Hasn't caused any issues until now AFAIK
Author
Owner

@schlich commented on GitHub (Sep 12, 2025):

In [Profile] > Additional Settings > Advanced there is a setting named "Launch this application with a new environment block"

Disable this setting for proper environment variable inheritance if you are spawning shells from WT.

@schlich commented on GitHub (Sep 12, 2025): In [Profile] > Additional Settings > Advanced there is a setting named "Launch this application with a new environment block" Disable this setting for proper environment variable inheritance if you are spawning shells from WT.
Author
Owner

@mostpinkest commented on GitHub (Jan 12, 2026):

For anyone looking to fix this in their own configuration, the ability for Windows Terminal to set custom environment variables was added in #15082 almost 3 years ago and since burried in the documentation.

You can set COLORTERM on a per profile basis or globally in the profile defaults by adding:

"environment": 
{
  "COLORTERM": "truecolor"
}

This avoids the need to modify your shell's profile or setting the environment variable at a system level, preserving compatibility if you ever wish to use a different terminal.

Given the foundation is evidently already implemented, I wouldn't think it'd be overly difficult to have COLORTERM=truecolor set by default, as it should be.

@mostpinkest commented on GitHub (Jan 12, 2026): For anyone looking to fix this in their own configuration, the ability for Windows Terminal to set custom environment variables was added in #15082 almost 3 years ago and since [burried in the documentation](https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#environment-variables-per-profile). You can set `COLORTERM` on a per profile basis or globally in the profile defaults by adding: ```json "environment": { "COLORTERM": "truecolor" } ``` This avoids the need to modify your shell's profile or setting the environment variable at a system level, preserving compatibility if you ever wish to use a different terminal. Given the foundation is evidently already implemented, I wouldn't think it'd be overly difficult to have `COLORTERM=truecolor` set by default, as it should be.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14987