Terminal: Feature Request: command or proprietary escape codes to set a tab's color

Created on 18 Jun 2020  路  5Comments  路  Source: microsoft/terminal

Description of the new feature/enhancement

The request is to be able to set a tab's color via a typed command, e.g. colortab red. iTerm2 does this via proprietary escape codes; this combination of three echo commands will color a tab pink:

echo -e "\033]6;1;bg;red;brightness;255\a"
echo -e "\033]6;1;bg;green;brightness;0\a"
echo -e "\033]6;1;bg;blue;brightness;255\a"

My scenario is that I want a .cmd file to be able to color its resulting tab without manual intervention, e.g. as a blue build process, a green chat bot, a red utility program, etc.

P.S. great job landing #2994!

Area-VT Help Wanted Issue-Task Product-Terminal

Most helpful comment

I believe this originally came from Eterm, which is why it doesn't share the typical XTerm color syntax. And to be honest, I'd probably recommend coming up with our own sequence if we want to support this functionality (or at least looking for an alternative that other terminals might be using). I can't see OSC 6 ever being widely used, because it already has at least two other meanings. In XTerm it's used to enable special colors. In Terminal.app and VTE it's used to set the current file path.

All 5 comments

Why the heck is that sequence formatted that way? Why isn't it just ^[]6;1;r;g;b^G?

I mean I'm generally fine with the idea, but I'd just imagine that they would have designed a better sequence tbh. What happens when you only emit

echo -e "\033]6;1;bg;red;brightness;255\a"

?

I could see this being useful as another alternative to #3004, where an app could change the tab color as a kind of notification.

I'm alright committing this to the backlog w/ Help Wanted. Yanking triage.

I believe this originally came from Eterm, which is why it doesn't share the typical XTerm color syntax. And to be honest, I'd probably recommend coming up with our own sequence if we want to support this functionality (or at least looking for an alternative that other terminals might be using). I can't see OSC 6 ever being widely used, because it already has at least two other meanings. In XTerm it's used to enable special colors. In Terminal.app and VTE it's used to set the current file path.

I had an idea for a sequence we could possibly use for this. On the DEC VT525, there's a DECAC (Assign Color) control sequence which is used to set the default foreground and background colors (essentially the equivalent of the XTerm OSC 10 and OSC 11 sequences). But it can also be used to set the _Window Frame_ color, which I think could be considered somewhat equivalent to our tabs.

The VT525 has a concept of multiple sessions, and when the _Frame Windows_ option is selected, a row of icons is displayed across the top of the screen to keep track of the different sessions, very similar in concept to tabs. You can see an image of a VT520 screen showing the session icons here:

https://i.imgur.com/8ujq0uN.jpg

The second session isn't named in that image, so it's not that obvious that you've got two sessions, but you can still see how similar those session identifiers are to tabs. This particular image is from a monochrome device, but I believe both the window frame and the icons would be displayed using the _Window Frame_ colors, so I don't think it would be unreasonable for us to also use those colors for our tabs.

Although now that I'm rereading the documentation, I realise you can only specify a color index when setting these colors. And technically the VT525 only supported index values in the range 0 to 15, but we could probably support all 256 colors from the XTerm color table and still be backwards compatible. But if you were hoping to be able to specify a full RGB value, then this isn't quite what you want.

Was this page helpful?
0 / 5 - 0 ratings