Display shell name as tab title instead of path by default #3126

Closed
opened 2026-01-30 23:13:41 +00:00 by claunia · 7 comments
Owner

Originally created by @19lmyers on GitHub (Aug 4, 2019).

The current default behavior of the Terminal is to display the full path by default.

image

This takes up a lot of space, limiting the number of visible tabs.
This is also a break from existing Microsoft-sanctioned Windows terminal applications - Command Prompt, PowerShell, and WSL (in my case, Ubuntu) all display their names in their titlebars.

image

Unfortunately, the new "tabTitle" setting does not effectively resolve this issue like I hoped it would. When this setting is used, the title specified cannot be overridden by programs executed in the shell.

Being able to see both the current shell and the currently running program in said shell is far more useful to me than knowing the exact path of the shell.

A solution could either be to allow the "tabTitle" feature to be overridden by the shell (I don't know if this is possible), or changing the default behavior of the Terminal to display the shell name instead of the path in the title bar.

Originally created by @19lmyers on GitHub (Aug 4, 2019). The current default behavior of the Terminal is to display the full path by default. ![image](https://user-images.githubusercontent.com/14363487/62429618-b8fe5900-b6c5-11e9-99b3-4d940ca65ed3.png) This takes up a lot of space, limiting the number of visible tabs. This is also a break from existing Microsoft-sanctioned Windows terminal applications - Command Prompt, PowerShell, and WSL (in my case, Ubuntu) all display their names in their titlebars. ![image](https://user-images.githubusercontent.com/14363487/62429627-d3d0cd80-b6c5-11e9-8b69-626d4f513ec9.png) Unfortunately, the new "tabTitle" setting does not effectively resolve this issue like I hoped it would. When this setting is used, the title specified _cannot be overridden_ by programs executed in the shell. Being able to see both the current shell and the currently running program in said shell is far more useful to me than knowing the exact path of the shell. A solution could either be to allow the "tabTitle" feature to be overridden by the shell (I don't know if this is possible), or changing the default behavior of the Terminal to display the shell name instead of the path in the title bar.
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-FixResolution-Answered labels 2026-01-30 23:13:41 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 4, 2019):

You’re right that when tabTitle isn’t set the shell can override the title. Why not use that shell overriding behavior to simply override the title when it’s too long? Then you can put whatever dynamic content in there you want!

@DHowett-MSFT commented on GitHub (Aug 4, 2019): You’re right that when tabTitle isn’t set the shell can override the title. Why not use that shell overriding behavior to simply override the title when it’s too long? Then you can put whatever dynamic content in there you want!
Author
Owner

@19lmyers commented on GitHub (Aug 5, 2019):

I'm not entirely sure what you mean. When I open any other Terminal app, it displays the shell name instead of the path. Why should extra shell scripting be required to replicate that?

@19lmyers commented on GitHub (Aug 5, 2019): I'm not entirely sure what you mean. When I open any other Terminal app, it displays the shell name instead of the path. Why should extra shell scripting be required to replicate that?
Author
Owner

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

When the Terminal is displaying the path in its tabs, that's actually a string that's being set by the shell (cmd/powershell) application. The Terminal isn't generating that text at all, it's only using the text that the shell requested to put there. When you use the tabTitle setting, you're effectively saying "I don't care what the shell wants the title to be, I want the title to be "foo"".

You can always configure your shell to set the title to something else. For example, bash sets the title with the following line in .bashrc: (by default)

PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 

What that line is saying is "I want you to set the title to <username>@<machine_name>: <path>". bash does this each time it evaluates your prompt.

In cmd it's a little easier, you can set the title of the window to "foo" with just title foo. I'm sure there's an equivalent way to do this with powershell as well.

"Other Terminal Apps" are actually all conhost.exe. They're using a poorly documented feature that allows a shortcut (.lnk) to override the shell's title value at launch. Conhost will use that value from the shortcut as the initial title for the window, but of course, changing the title by any mechanism will just overwrite that value. I'm pretty sure Powershell will actively work to persist that title if it finds it, and I'm fairly certain cmd.exe will only set the title to the path on launch if it doesn't find another title.

Also looping in #2218

@zadjii-msft commented on GitHub (Aug 5, 2019): When the Terminal is displaying the path in its tabs, that's actually a string that's being set by the shell (cmd/powershell) application. The Terminal isn't generating that text at all, it's only using the text that the shell requested to put there. When you use the `tabTitle` setting, you're effectively saying "I don't care what the shell wants the title to be, I want the title to be `"foo"`". You can always configure your shell to set the title to something else. For example, `bash` sets the title with the following line in `.bashrc`: (by default) ```bash PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ``` What that line is saying is "I want you to set the title to `<username>@<machine_name>: <path>`". `bash` does this each time it evaluates your prompt. In cmd it's a little easier, you can set the title of the window to "foo" with just `title foo`. I'm sure there's an equivalent way to do this with powershell as well. "Other Terminal Apps" are actually all conhost.exe. They're using a poorly documented feature that allows a shortcut (`.lnk`) to override the shell's title value _at launch_. Conhost will use that value from the shortcut as the initial title for the window, but of course, changing the title by any mechanism will just overwrite that value. I'm pretty sure Powershell will actively work to persist that title if it finds it, and I'm fairly certain cmd.exe will only set the title to the path _on launch_ if it doesn't find another title. Also looping in #2218
Author
Owner

@19lmyers commented on GitHub (Aug 5, 2019):

So what's the best way to replicate the behavior of conhost in Windows
Terminal for cmd and PowerShell?

(I've also noticed that my WSL distro starts in a different directory and
shows a different icon than the conhost-based shell, but that's a separate
issue.)

On Mon, Aug 5, 2019, 6:20 AM Mike Griese notifications@github.com wrote:

When the Terminal is displaying the path in its tabs, that's actually a
string that's being set by the shell (cmd/powershell) application. The
Terminal isn't generating that text at all, it's only using the text that
the shell requested to put there. When you use the tabTitle setting,
you're effectively saying "I don't care what the shell wants the title to
be, I want the title to be "foo"".

You can always configure your shell to set the title to something else.
For example, bash sets the title with the following line in .bashrc: (by
default)

PS1="[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1"

What that line is saying is "I want you to set the title to @<machine_name>:
". bash does this each time it evaluates your prompt.

In cmd it's a little easier, you can set the title of the window to "foo"
with just title foo. I'm sure there's an equivalent way to do this with
powershell as well.

"Other Terminal Apps" are actually all conhost.exe. They're using a poorly
documented feature that allows a shortcut (.lnk) to override the shell's
title value at launch. Conhost will use that value from the shortcut as
the initial title for the window, but of course, changing the title by any
mechanism will just overwrite that value. I'm pretty sure Powershell will
actively work to persist that title if it finds it, and I'm fairly certain
cmd.exe will only set the title to the path on launch if it doesn't
find another title.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/terminal/issues/2241?email_source=notifications&email_token=ADNSWX7AQKI3PBWSUACZUUTQDASKHA5CNFSM4IJGJRWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3RZHJA#issuecomment-518230948,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADNSWX6X3RM6RLBFKJB7VBLQDASKHANCNFSM4IJGJRWA
.

--

Sent from Inbox

@19lmyers commented on GitHub (Aug 5, 2019): So what's the best way to replicate the behavior of conhost in Windows Terminal for cmd and PowerShell? (I've also noticed that my WSL distro starts in a different directory and shows a different icon than the conhost-based shell, but that's a separate issue.) On Mon, Aug 5, 2019, 6:20 AM Mike Griese <notifications@github.com> wrote: > When the Terminal is displaying the path in its tabs, that's actually a > string that's being set by the shell (cmd/powershell) application. The > Terminal isn't generating that text at all, it's only using the text that > the shell requested to put there. When you use the tabTitle setting, > you're effectively saying "I don't care what the shell wants the title to > be, I want the title to be "foo"". > > You can always configure your shell to set the title to something else. > For example, bash sets the title with the following line in .bashrc: (by > default) > > PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" > > What that line is saying is "I want you to set the title to <username>@<machine_name>: > <path>". bash does this each time it evaluates your prompt. > > In cmd it's a little easier, you can set the title of the window to "foo" > with just title foo. I'm sure there's an equivalent way to do this with > powershell as well. > > "Other Terminal Apps" are actually all conhost.exe. They're using a poorly > documented feature that allows a shortcut (.lnk) to override the shell's > title value *at launch*. Conhost will use that value from the shortcut as > the initial title for the window, but of course, changing the title by any > mechanism will just overwrite that value. I'm pretty sure Powershell will > actively work to persist that title if it finds it, and I'm fairly certain > cmd.exe will only set the title to the path *on launch* if it doesn't > find another title. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/microsoft/terminal/issues/2241?email_source=notifications&email_token=ADNSWX7AQKI3PBWSUACZUUTQDASKHA5CNFSM4IJGJRWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3RZHJA#issuecomment-518230948>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/ADNSWX6X3RM6RLBFKJB7VBLQDASKHANCNFSM4IJGJRWA> > . > -- Sent from Inbox
Author
Owner

@AlesRFK commented on GitHub (May 11, 2020):

If anyone needs the opposites :D (Windows Terminal PS)
Code_2020-05-11_16-03-58

@AlesRFK commented on GitHub (May 11, 2020): If anyone needs the opposites :D (Windows Terminal PS) ![Code_2020-05-11_16-03-58](https://user-images.githubusercontent.com/13176180/81570778-58f9b900-93a1-11ea-9b3c-097453b4ebd7.png)
Author
Owner

@sugatoray commented on GitHub (Oct 27, 2020):

Setting "suppressApplicationTitle": true enforces the use of the tabTitle parameter.

{
    // ubuntu profile
    "guid": "{<your-guid>}",
    "name": "Ubuntu", 
    "tabTitle": "Ubuntu-Tab", 
    "suppressApplicationTitle": true, // set it "true" to enforce the use of "tabTitle", 
    "tabColor": "#DC143C",
    "source": "Windows.Terminal.Wsl",
    "fontFace": "Cascadia Code PL",
    "colorScheme": "One Half Dark", 
    "useAcrylic": true,
    "acrylicOpacity": 0.8
}
@sugatoray commented on GitHub (Oct 27, 2020): Setting `"suppressApplicationTitle": true` enforces the use of the `tabTitle` parameter. ```jsonc { // ubuntu profile "guid": "{<your-guid>}", "name": "Ubuntu", "tabTitle": "Ubuntu-Tab", "suppressApplicationTitle": true, // set it "true" to enforce the use of "tabTitle", "tabColor": "#DC143C", "source": "Windows.Terminal.Wsl", "fontFace": "Cascadia Code PL", "colorScheme": "One Half Dark", "useAcrylic": true, "acrylicOpacity": 0.8 } ```
Author
Owner

@hardmanhong commented on GitHub (Aug 23, 2021):

# Microsoft.PowerShell_profile.ps1
function Prompt
{
  $paths = ((get-location).toString().split("\"));
  $host.ui.RawUI.WindowTitle = $paths[$paths.length -1]
  "PS " + $(get-location) + "> "
}
@hardmanhong commented on GitHub (Aug 23, 2021): ```bash # Microsoft.PowerShell_profile.ps1 function Prompt { $paths = ((get-location).toString().split("\")); $host.ui.RawUI.WindowTitle = $paths[$paths.length -1] "PS " + $(get-location) + "> " } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3126