Add a guide for setting the title in your shell #3218

Closed
opened 2026-01-30 23:16:03 +00:00 by claunia · 4 comments
Owner

Originally created by @zadjii-msft on GitHub (Aug 6, 2019).

Originally assigned to: @cinnamon-msft on GitHub.

This has come up like 15 times in the last 5 days since 0.3 dropped.

It's clear that most users don't know that you can set the title of the console window with your shell. We should create a user doc that shows how to change the title in various shells. I'm thinking we definitely need powershell, cmd and bash.

Ideally, we'll have steps on how to update the title as part of the prompt for each of these shells too. Obviously this wouldn't work great for cmd.exe, since cmd doesn't re-evaluate the PROMPT each time. However, bash already updates the title as part of the prompt, and I know that's possible with powershell too.

Can users just google this themselves? Yes, but this seems like something that users don't even know is a scenario that's possible, so they wouldn't think to look for it.

Originally created by @zadjii-msft on GitHub (Aug 6, 2019). Originally assigned to: @cinnamon-msft on GitHub. <!-- Briefly describe which document needs to be corrected and why. --> This has come up like 15 times in the last 5 days since 0.3 dropped. It's clear that most users _don't_ know that you can set the title of the console window with your shell. We should create a user doc that shows how to change the title in various shells. I'm thinking we definitely need `powershell`, `cmd` and `bash`. Ideally, we'll have steps on how to update the title as part of the prompt for each of these shells too. Obviously this wouldn't work great for cmd.exe, since cmd doesn't re-evaluate the PROMPT each time. However, bash already updates the title as part of the prompt, and I _know_ that's possible with powershell too. Can users just google this themselves? _Yes_, but this seems like something that users don't even know is a scenario that's possible, so they wouldn't think to look for it.
claunia added the Resolution-Fix-AvailableArea-SettingsProduct-TerminalIssue-Docs labels 2026-01-30 23:16:04 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Aug 6, 2019):

Wait hol up, this would work okay with cmd.exe.

set PROMPT=$e]0;$p$e\$p$g

The $e]0;$p$e\ sets the title to the path. As long as the stuff between $e]0; and $e\ is from this list, then it'll work fine in the title. Unfortunately environment variables are evaluated when the prompt is set, not when it is displayed in cmd, so you can't really use any env vars in cmd, without re-setting the %PROMPT% variable each time.

@zadjii-msft commented on GitHub (Aug 6, 2019): Wait hol up, this would work _okay_ with cmd.exe. ```cmd set PROMPT=$e]0;$p$e\$p$g ``` The `$e]0;$p$e\` sets the title to the path. As long as the stuff between `$e]0;` and `$e\` is from [this list](https://ss64.com/nt/prompt.html), then it'll work fine in the title. Unfortunately environment variables are evaluated _when the prompt is set_, not _when it is displayed_ in cmd, so you can't really use any env vars in cmd, without re-setting the `%PROMPT%` variable each time.
Author
Owner

@sassdawe commented on GitHub (Aug 7, 2019):

@zadjii-msft I was using this property in PowerShell in the past couple of years to update the title: $host.ui.RawUI.WindowTitle and I've realized that I need something else to update the Title of the Terminal per tab and not the title of the tab.
I prefer to put the current directory into the title of the window and if I update the title of the tab that would always change the size of the tab so instead/next to updating the title of the tab I think we need a way to update the title of the terminal window as well.

@sassdawe commented on GitHub (Aug 7, 2019): @zadjii-msft I was using this property in `PowerShell` in the past couple of years to update the title: `$host.ui.RawUI.WindowTitle` and I've realized that I need something else to update the Title of the Terminal per tab and not the title of the tab. I prefer to put the current directory into the title of the window and if I update the title of the tab that would always change the size of the tab so instead/next to updating the title of the tab I think we need a way to update the title of the terminal window as well.
Author
Owner

@DerekSMorin commented on GitHub (Sep 5, 2019):

I don't know why my brain took so long to pick up on this, but
set PROMPT=$e]0;$p$e$p$g
works really well for what I want.

AND if I set it as a permanent environment variable then it will work for new "cmd" and terminal windows.

@DerekSMorin commented on GitHub (Sep 5, 2019): I don't know why my brain took so long to pick up on this, but set PROMPT=$e]0;$p$e\$p$g works really well for what I want. **AND** if I set it as a permanent environment variable then it will work for new "cmd" and terminal windows.
Author
Owner

@zadjii-msft commented on GitHub (May 26, 2020):

Hey this looks like it was added to https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title, so I'm closing this issue out. Thanks all!

@zadjii-msft commented on GitHub (May 26, 2020): Hey this looks like it was added to https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title, so I'm closing this issue out. Thanks all!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3218