Feature Request: Ability to Set Tab Color Programmatically #16490
Replies: 6 comments 6 replies
-
If shell can work with json then this is easy to do: |
Beta Was this translation helpful? Give feedback.
-
Dmitry, Thank you for the quick response. I'm not by any means a PowerShell expert (I use it out of necessity) but it does have json support. Before I hack something up, I want to be sure I understand this. Wouldn't changing the profile change EVERY powershell tab color? I typically have six instances open in Windows Terminal (two split windows in three separate tabs). I don't want to update the tabs of every instance of that profile, and while I could create a separate profile for each tab, that comes with its own management issues. |
Beta Was this translation helpful? Give feedback.
-
No, it will change tabColor of all of profile instances. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
You can use an escape sequence to set the tab color of the active tab. For example, in PowerShell, you can make it red with:
In bash, it would be something like this:
It's the last number in that sequence that specifies the background color: 1 is red, 2 is green, 3 is yellow, etc. The 15 represents the foreground color, but doesn't currently have any effect in Windows Terminal (the foreground is automatically assigned a contrasting color). |
Beta Was this translation helpful? Give feedback.
-
[Edit] I figured out the problem. Apparently if the tab is launched with the --tabColor explicitly set it can't be overridden with escape commands. If I simply launch a new shell without them it works fine, although that hampers my standard launch which is a powershell script that takes the type of shell I want to launch and colorizes it, changes directory, sets the posh line, etc. The main launch sequence is:
Curses? Wow, that takes me ... way ... back! @j4james I tried your curses commands in both PowerShell and linux with no success. I tried a few other curses commands such as "`e[34;42m" which correctly changed my fg/bg to black on green so it doesn't appear to be a configuration issue. I'm running Windows Terminal Preview Version: 1.19.3172.0 if that matters. |
Beta Was this translation helpful? Give feedback.
-
This might be a very niche request, but I have a use case that would really benefit from having the ability to set the tab color from a shell script. I often run builds or tests that take a fair bit of time to complete and being able to set the tab color of a background tab dynamically based on the outcome would be very useful.
Currently I set the title dynamically using
$Host.UI.RawUI.WindowTitle = $title
but it lacks the impact of turning a tab bright green or red when something succeeds or fails. There is the ability to set individual tab colors when launching a new tab, so it seems like a strange omission that there isn't a similar dynamic$Host.UI.RawUI.WindowColor = $color
capability.Beta Was this translation helpful? Give feedback.
All reactions