When does WT set a tab's title? #15801

Closed
opened 2026-01-31 04:48:47 +00:00 by claunia · 5 comments
Owner

Originally created by @vefatica on GitHub (Nov 7, 2021).

I let my shells control the title of the console/tab. But occasionally, I'll see WT's title (profile name) on the tab. Under what circumstances does WT set the title if apps are allowed to do it? Thanks!

Originally created by @vefatica on GitHub (Nov 7, 2021). I let my shells control the title of the console/tab. But occasionally, I'll see WT's title (profile name) on the tab. Under what circumstances does WT set the title if apps are allowed to do it? Thanks!
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 04:48:47 +00:00
Author
Owner

@eryksun commented on GitHub (Nov 7, 2021):

In my experience, the initial tab title is, in increasing order of priority, based on the profile name, the tab title that's configured in the profile (i.e. the "tabTitle" setting), or the "--title" command-line option. For example: wt -w 0 nt --title "Spam" -p "Command Prompt" runs the "Command Prompt" profile in a new tab with the title "Spam".

If Windows Terminal is set as the default terminal application, and a new terminal/tab is created for a console application, the initial title is the lpTitle field of the process STARTUPINFO. For example, from an existing CMD shell: start "Spam" cmd.exe would run CMD in a new tab with the title "Spam". If a console application is started from a shell link (i.e. ".LNK" file), the STARTF_TITLEISLINKNAME flag is set in the process STARTUPINFO, in which case lpTitle is the full path of the shell link. In this case, the classic console (conhost) uses just the base name of the shell link as the title, without the ".LNK" extension, but Windows Terminal uses the full path of the shell link as the title. I prefer the behavior of the classic console in this case.

An application can change the console window or tab title either using the virtual terminal OSC sequence or the SetConsoleTitle() API function.

@eryksun commented on GitHub (Nov 7, 2021): In my experience, the initial tab title is, in increasing order of priority, based on the profile name, the tab title that's configured in the profile (i.e. the "tabTitle" setting), or the "--title" command-line option. For example: `wt -w 0 nt --title "Spam" -p "Command Prompt"` runs the "Command Prompt" profile in a new tab with the title "Spam". If Windows Terminal is set as the default terminal application, and a new terminal/tab is created for a console application, the initial title is the `lpTitle` field of the process [`STARTUPINFO`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow). For example, from an existing CMD shell: `start "Spam" cmd.exe` would run CMD in a new tab with the title "Spam". If a console application is started from a shell link (i.e. ".LNK" file), the `STARTF_TITLEISLINKNAME` flag is set in the process `STARTUPINFO`, in which case `lpTitle` is the full path of the shell link. In this case, the classic console (conhost) uses just the base name of the shell link as the title, without the ".LNK" extension, but Windows Terminal uses the full path of the shell link as the title. I prefer the behavior of the classic console in this case. An application can change the console window or tab title either using the virtual terminal [OSC sequence](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#window-title) or the [`SetConsoleTitle()`](https://docs.microsoft.com/en-us/windows/console/setconsoletitle) API function.
Author
Owner

@vefatica commented on GitHub (Nov 7, 2021):

Terminal as the default is not an option here. In my default shell (TCC.EXE) I normally see the likes of this.

image

That's governed by a TITLEPROMPT environment variable and an "UpdateTitle=No" option which prevents showing the current command. Often, when I issue a compound command (as in the pic below) the title changes to "TCC28". That's the profile's name.

image

I doubt TCC is causing the startup title to be used because it doesn't happen in a console (and TCC is otherwise unaware of the profile's name).

image

Are there conditions under which WT would do that?

@vefatica commented on GitHub (Nov 7, 2021): Terminal as the default is not an option here. In my default shell (TCC.EXE) I normally see the likes of this. ![image](https://user-images.githubusercontent.com/61856645/140658304-3acbeef7-fe6f-4830-9fbd-1bd7521d4519.png) That's governed by a TITLEPROMPT environment variable and an "UpdateTitle=No" option which prevents showing the current command. Often, when I issue a compound command (as in the pic below) the title changes to "TCC28". That's the profile's name. ![image](https://user-images.githubusercontent.com/61856645/140658460-cdd721a2-e736-4bec-b4e7-9e7cf83967a6.png) I doubt TCC is causing the startup title to be used because it doesn't happen in a console (and TCC is otherwise unaware of the profile's name). ![image](https://user-images.githubusercontent.com/61856645/140658702-7783b9fd-728b-4ce3-b515-2b9cdb41976c.png) Are there conditions under which WT would do that?
Author
Owner

@eryksun commented on GitHub (Nov 7, 2021):

Windows Terminal is not responsible for changing to the original title. tcc.exe saves the original title and changes back to it via SetConsoleTitlteW(). I attached a debugger to the process to confirm this. It doesn't do this if the original title is the full path of tcc.exe, or when it's run from a shell link. Note that CreateProcessW() defaults the title to the full path of the executable if the lpTitle field in the STARTUPINFO is NULL.

To observe the title-changing behavior of TCC without Windows Terminal, run it with a custom title in the classic console via start "custom title" path\to\tcc.exe.

You can work around this in Windows Terminal by setting the profile's tab title to the full path of tcc.exe, which in my case is "C:\Program Files\JPSoft\TCCLE14x64\tcc.exe". TCC detects this and automatically changes the title to "TCC LE Prompt". After setting TITLEPROMPT=SPAM, for example, the title stays as just "SPAM" throughout the echo foo & delay 15 command.

@eryksun commented on GitHub (Nov 7, 2021): Windows Terminal is not responsible for changing to the original title. tcc.exe saves the original title and changes back to it via `SetConsoleTitlteW()`. I attached a debugger to the process to confirm this. It doesn't do this if the original title is the full path of tcc.exe, or when it's run from a shell link. Note that `CreateProcessW()` defaults the title to the full path of the executable if the `lpTitle` field in the `STARTUPINFO` is `NULL`. To observe the title-changing behavior of TCC without Windows Terminal, run it with a custom title in the classic console via `start "custom title" path\to\tcc.exe`. You can work around this in Windows Terminal by setting the profile's tab title to the full path of tcc.exe, which in my case is "C:\\Program Files\\JPSoft\\TCCLE14x64\\tcc.exe". TCC detects this and automatically changes the title to "TCC LE Prompt". After setting `TITLEPROMPT=SPAM`, for example, the title stays as just "SPAM" throughout the `echo foo & delay 15` command.
Author
Owner

@vefatica commented on GitHub (Nov 7, 2021):

I also saw TCC do that using WinDbg (and I wonder why, given my settings). It didn't do it in a console. I'll investigate further and try your suggestion. Since this doesn't seem to have much to do with WT, I'll close the issue. Thank you, @eryksun.

@vefatica commented on GitHub (Nov 7, 2021): I also saw TCC do that using WinDbg (and I wonder why, given my settings). It didn't do it in a console. I'll investigate further and try your suggestion. Since this doesn't seem to have much to do with WT, I'll close the issue. Thank you, @eryksun.
Author
Owner

@vefatica commented on GitHub (Nov 7, 2021):

P.S., Your work-around worked. Thanks again!

@vefatica commented on GitHub (Nov 7, 2021): P.S., Your work-around worked. Thanks again!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15801