Ability to rename Tab title at runtime #1440

Closed
opened 2026-01-30 22:27:08 +00:00 by claunia · 60 comments
Owner

Originally created by @dhavalhirdhav on GitHub (May 31, 2019).

Originally assigned to: @zadjii-msft on GitHub.

Tabs are very useful feature, but as you open more and more tabs, it becomes difficult and confusing to keep track of which tab is for which purpose unless you the tab. It will be better if we can rename the Tab and give it a friendly name.

The way we can implement the tab renaming from functional point of view is:

1 - Right click -> Rename

Right click on a tab which user wants to rename, this will open up context menu and from context Menu, user will select Rename.

Title of the tab will change into a TextBox, and user will be able to write Tab name, and on hitting enter key on the keyboard or clicking anywhere outside the textbox will apply the tab title. If user presses ESC key, we will discard the changes.

image

2 - Double click - tab title

Title of the tab will change into a TextBox, and user will be able to write Tab name, and on hitting enter key on the keyboard or clicking anywhere outside the textbox will apply the tab title. If user presses ESC key, we will discard the changes.

Final result will look like:

image

Originally created by @dhavalhirdhav on GitHub (May 31, 2019). Originally assigned to: @zadjii-msft on GitHub. Tabs are very useful feature, but as you open more and more tabs, it becomes difficult and confusing to keep track of which tab is for which purpose unless you the tab. It will be better if we can rename the Tab and give it a friendly name. The way we can implement the tab renaming from functional point of view is: 1 - Right click -> Rename Right click on a tab which user wants to rename, this will open up context menu and from context Menu, user will select Rename. Title of the tab will change into a TextBox, and user will be able to write Tab name, and on hitting enter key on the keyboard or clicking anywhere outside the textbox will apply the tab title. If user presses ESC key, we will discard the changes. ![image](https://user-images.githubusercontent.com/517661/58713357-00bfe600-83e0-11e9-9032-b0911121c845.png) 2 - Double click - tab title Title of the tab will change into a TextBox, and user will be able to write Tab name, and on hitting enter key on the keyboard or clicking anywhere outside the textbox will apply the tab title. If user presses ESC key, we will discard the changes. Final result will look like: ![image](https://user-images.githubusercontent.com/517661/58713549-6c09b800-83e0-11e9-8357-608479913bbe.png)
Author
Owner

@mdtauk commented on GitHub (May 31, 2019):

Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead?

The path is usually there in the pompt, so not sure its needed in both.

@mdtauk commented on GitHub (May 31, 2019): Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead? The path is usually there in the pompt, so not sure its needed in both.
Author
Owner

@DHowett-MSFT commented on GitHub (May 31, 2019):

The path is there because it is what the shell has put there. For discussions about that and the merits of titles, #608. This is a slightly different ask.

@DHowett-MSFT commented on GitHub (May 31, 2019): The path is there because it is what the shell has _put_ there. For discussions about that and the merits of titles, #608. This is a slightly different ask.
Author
Owner

@dhavalhirdhav commented on GitHub (May 31, 2019):

Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead?

The path is usually there in the pompt, so not sure its needed in both.

Profile just shows the CMD or PowerShell.. but what I am proposing is to be able to rename Tab with a friendly name.

@dhavalhirdhav commented on GitHub (May 31, 2019): > Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead? > > The path is usually there in the pompt, so not sure its needed in both. Profile just shows the CMD or PowerShell.. but what I am proposing is to be able to rename Tab with a friendly name.
Author
Owner

@zadjii-msft commented on GitHub (May 31, 2019):

I'm pretty sure this is a subset of one of the solutions I proposed in that thread:

If we went with just 2 modes, we could do it in the two possible ways:

  1. Add an optional titleText:string string to the profile. If that's set, then we'll display that string instead of the terminal's title.
  • this has the downside of not defaulting to the profile name. The user would manually need to set that string.
  • if the profile name changes, then the user would have to manually change this as well.
  • it might not be abundantly clear that titleText means we'll be using that instead of the terminal's title, but ideally the settings UI will explain this better, and the actual key doesn't matter so much.
@zadjii-msft commented on GitHub (May 31, 2019): I'm pretty sure this is a subset of one of the solutions I proposed in that thread: > If we went with just 2 modes, we could do it in the two possible ways: > 1. Add an optional `titleText:string` string to the profile. If that's set, then we'll display that string instead of the terminal's title. > - this has the downside of not defaulting to the profile name. The user would manually need to set that string. > - if the profile name changes, then the user would have to manually change this as well. > - it might not be abundantly clear that `titleText` means we'll be using that instead of the terminal's title, but ideally the settings UI will explain this better, and the actual key doesn't matter so much.
Author
Owner

@mdtauk commented on GitHub (May 31, 2019):

Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead?
The path is usually there in the pompt, so not sure its needed in both.

Profile just shows the CMD or PowerShell.. but what I am proposing is to be able to rename Tab with a friendly name.

Renaming the tab would imply the name is there until that tab is closed. My suggestion would be to allow a profile to have a name chosen by the user

@mdtauk commented on GitHub (May 31, 2019): > > Couldn't the Profile name be used for the tab title by default, but maybe an option to display a path instead? > > The path is usually there in the pompt, so not sure its needed in both. > >Profile just shows the CMD or PowerShell.. but what I am proposing is to be able to rename Tab with a friendly name. > Renaming the tab would imply the name is there until that tab is closed. My suggestion would be to allow a profile to have a name chosen by the user
Author
Owner

@zadjii-msft commented on GitHub (May 31, 2019):

Though, I guess I leave this open to track specifically adding a button to the tab right click menu to set the profile's TitleText.


er, now that I've typed this up, maybe we should have a runtime text we modify. I'm thinking in the case where a user has multiple tabs with the same profile open. If the user want to rename one of the tabs, they probably don't want that name applied globally to each of the tabs with that profile. They probably just want to rename that _one_ tab.

So this should involve setting a flag on the Tab that it's using a runtime title as opposed to the title from the control, and we should just ignore all title changes from the control. If the profile's title setting is changed, then we'll ignore that also.

Though a question here would be should that custom string apply to the Tab or the focused Pane? I'd probably presume it'd apply to the Tab, not the Pane.

@zadjii-msft commented on GitHub (May 31, 2019): Though, I guess I leave this open to track specifically adding a button to the tab right click menu to set the profile's TitleText. <hr> er, now that I've typed this up, maybe we should have a runtime text we modify. I'm thinking in the case where a user has multiple tabs with the same profile open. If the user want to rename one of the tabs, they probably don't want that name applied globally to each of the tabs with that profile. They probably just want to rename that _one_ tab. So this should involve setting a flag on the Tab that it's using a runtime title as opposed to the title from the control, and we should just ignore all title changes from the control. If the profile's title setting is changed, then we'll ignore that also. Though a question here would be should that custom string apply to the Tab or the focused Pane? I'd probably presume it'd apply to the Tab, not the Pane.
Author
Owner

@dhavalhirdhav commented on GitHub (May 31, 2019):

@zadjii-msft it should apply to tab. Also if it clear text, it should set runtime flag to false. This will also enable tab to start using profile name.

@dhavalhirdhav commented on GitHub (May 31, 2019): @zadjii-msft it should apply to tab. Also if it clear text, it should set runtime flag to false. This will also enable tab to start using profile name.
Author
Owner

@DHowett-MSFT commented on GitHub (May 31, 2019):

@carlos-zamora wanted to work on tab actions, and I think this is a pretty good fit. He even suggested it! So here’s the deal: there’s clearly three different schools of thought here regarding title, so this is now Spec Needed. 😄

@DHowett-MSFT commented on GitHub (May 31, 2019): @carlos-zamora wanted to work on tab actions, and I think this is a pretty good fit. He even suggested it! So here’s the deal: there’s clearly three different schools of thought here regarding title, so this is now `Spec Needed`. :smile:
Author
Owner

@carlos-zamora commented on GitHub (May 31, 2019):

@carlos-zamora wanted to work on tab actions, and I think this is a pretty good fit. He even suggested it! So here’s the deal: there’s clearly three different schools of thought here regarding title, so this is now Spec Needed. 😄

YES! I really want this feature. Definitely a question of how this interacts with the shell/distro sending a title up to the tab (#608). I also noticed that the hovering action should be included in this (i.e.: hovering over tab displays the full path beneath the mouse [try on Edge]). @cinnamon-msft and I will draft up a spec soon. We're super excited!

@carlos-zamora commented on GitHub (May 31, 2019): > @carlos-zamora wanted to work on tab actions, and I think this is a pretty good fit. He even suggested it! So here’s the deal: there’s clearly three different schools of thought here regarding title, so this is now `Spec Needed`. 😄 YES! I really want this feature. Definitely a question of how this interacts with the shell/distro sending a title up to the tab (#608). I also noticed that the hovering action should be included in this (i.e.: hovering over tab displays the full path beneath the mouse [try on Edge]). @cinnamon-msft and I will draft up a spec soon. We're super excited!
Author
Owner

@dhavalhirdhav commented on GitHub (May 31, 2019):

Suepr. Let me know how I can as a developer contribute.

@dhavalhirdhav commented on GitHub (May 31, 2019): Suepr. Let me know how I can as a developer contribute.
Author
Owner

@phuclv90 commented on GitHub (Jun 2, 2019):

Note that you can also set the title from command line with title "new title" in cmd and $Host.UI.RawUI.WindowTitle = "new title" in powershell

@phuclv90 commented on GitHub (Jun 2, 2019): Note that you can also set the title from command line with `title "new title"` in cmd and `$Host.UI.RawUI.WindowTitle = "new title"` in powershell
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 3, 2019):

We should use #608 to track tab titling issues. Thanks!

@DHowett-MSFT commented on GitHub (Jun 3, 2019): We should use #608 to track tab titling issues. Thanks!
Author
Owner

@tvsbrent commented on GitHub (Jul 30, 2019):

Note that you can also set the title from command line with title "new title" in cmd and $Host.UI.RawUI.WindowTitle = "new title" in powershell

Very helpful! I added a function to my Powershell Profile to let me set it more easily:

function Set-Title {
    param(
        [string]
        $title
    )
    $Host.UI.RawUI.WindowTitle = $title   
}
@tvsbrent commented on GitHub (Jul 30, 2019): > Note that you can also set the title from command line with `title "new title"` in cmd and `$Host.UI.RawUI.WindowTitle = "new title"` in powershell Very helpful! I added a function to my Powershell Profile to let me set it more easily: ``` function Set-Title { param( [string] $title ) $Host.UI.RawUI.WindowTitle = $title } ```
Author
Owner

@loliconer commented on GitHub (Aug 28, 2019):

Note that you can also set the title from command line with title "new title" in cmd and $Host.UI.RawUI.WindowTitle = "new title" in powershell

When running npm tasks, such as npm run serve, the title will become npm.

@loliconer commented on GitHub (Aug 28, 2019): > Note that you can also set the title from command line with `title "new title"` in cmd and `$Host.UI.RawUI.WindowTitle = "new title"` in powershell When running npm tasks, such as `npm run serve`, the title will become `npm`.
Author
Owner

@greggbjensen commented on GitHub (Sep 17, 2019):

A simple way to set a name for the open tabs would go a long way in making it even more useful. With several PowerShell tabs open, I find it difficult to know which one I am trying to work in.

@greggbjensen commented on GitHub (Sep 17, 2019): A simple way to set a name for the open tabs would go a long way in making it even more useful. With several PowerShell tabs open, I find it difficult to know which one I am trying to work in.
Author
Owner

@phuclv90 commented on GitHub (Sep 18, 2019):

@greggbjensen just use a function or alias like tvsbrent's comment above

@phuclv90 commented on GitHub (Sep 18, 2019): @greggbjensen just use a function or alias like tvsbrent's comment above
Author
Owner

@greggbjensen commented on GitHub (Sep 18, 2019):

@phuclv90 a right click to quickly set the name would still be much faster and simpler. It seems needed if you plan on having a lot of tabs. The ability to set colors of the tabs would also be a good addition.

@greggbjensen commented on GitHub (Sep 18, 2019): @phuclv90 a right click to quickly set the name would still be much faster and simpler. It seems needed if you plan on having a lot of tabs. The ability to set colors of the tabs would also be a good addition.
Author
Owner

@zadjii-msft commented on GitHub (Oct 31, 2019):

It would be really nice to be able to rename tabs by just double-clicling them and setting new title in some kind of text-box. This name replaces original title and stays until tab closed or renamed again.

Originally posted by @Vasiliy-Bondarenko in #3387
@zadjii-msft commented on GitHub (Oct 31, 2019): > It would be really nice to be able to rename tabs by just double-clicling them and setting new title in some kind of text-box. This name replaces original title and stays until tab closed or renamed again. ##### Originally posted by @Vasiliy-Bondarenko in #3387
Author
Owner

@xoofx commented on GitHub (Nov 20, 2019):

Please allow to rename tab with a friendly name easily from the UI, this is one feature I'm using constantly with ConEmu and one reason I don't switch to Windows Terminal yet, as it is not enough practical when you have many "well known" tabs opened but can't figure this out easily this in Windows Terminal

@xoofx commented on GitHub (Nov 20, 2019): Please allow to rename tab with a friendly name easily from the UI, this is one feature I'm using constantly with ConEmu and one reason I don't switch to Windows Terminal yet, as it is not enough practical when you have many "well known" tabs opened but can't figure this out easily this in Windows Terminal
Author
Owner

@xoofx commented on GitHub (Nov 25, 2019):

Just discovered that I can at least workaround the title in WSL with a function added to .bashrc that can be called from the prompt e.g. title "my title":

title() {
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}$1\a\]\[\033[01;34m\]\w\[\033[00m\]> "
}
@xoofx commented on GitHub (Nov 25, 2019): Just discovered that I can at least workaround the title in WSL with a function added to `.bashrc` that can be called from the prompt e.g. `title "my title"`: ```bash title() { PS1="\[\e]0;${debian_chroot:+($debian_chroot)}$1\a\]\[\033[01;34m\]\w\[\033[00m\]> " } ```
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 25, 2019):

That’s not actually a workaround, that’s the best and most flexible and robust way to set the title of almost any terminal window. It can be dynamic, it works over SSH, and it can incorporate things only available on the remote host.

@DHowett-MSFT commented on GitHub (Nov 25, 2019): That’s not actually a _workaround_, that’s the best and most flexible and robust way to set the title of almost any terminal window. It can be dynamic, it works over SSH, and it can incorporate things only available on the remote host.
Author
Owner

@quanticle commented on GitHub (Feb 13, 2020):

I modified the solution posted by @xoofx to not modify the prompt in the terminal itself:

title() {
    PS1="\[\e]0;$* \a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
}

It looks a bit ugly, but if you put that in your ~/.bashrc, you'll be able to call title <title_text> and it'll set tab/window title, but it won't mess with the default prompt.

@quanticle commented on GitHub (Feb 13, 2020): I modified the solution posted by @xoofx to not modify the prompt in the terminal itself: ```bash title() { PS1="\[\e]0;$* \a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " } ``` It looks a bit ugly, but if you put that in your `~/.bashrc`, you'll be able to call `title <title_text>` and it'll set tab/window title, but it won't mess with the default prompt.
Author
Owner

@johnc44 commented on GitHub (Feb 18, 2020):

In iTerm on the Mac I can do this and it's really useful. I can also set the tab colour which is quite nice.

I almost exclusively use Ubuntu WSL in Windows Terminal, and all my tabs show "myname@mycomputer/c/g" where "g" is the first letter of the root directory where all my projects are. It's completely useless to me. No doubt there is some way to change it, but a user-friendly way would be nice.

@johnc44 commented on GitHub (Feb 18, 2020): In iTerm on the Mac I can do this and it's really useful. I can also set the tab colour which is quite nice. I almost exclusively use Ubuntu WSL in Windows Terminal, and all my tabs show "myname@mycomputer/c/g" where "g" is the first letter of the root directory where all my projects are. It's completely useless to me. No doubt there is some way to change it, but a user-friendly way would be nice.
Author
Owner

@trongpham-itr commented on GitHub (Feb 20, 2020):

:))) I am using WSL. I want to rename the tab "my monitor", I used: "my monitor ; source run.sh"

@trongpham-itr commented on GitHub (Feb 20, 2020): :))) I am using WSL. I want to rename the tab "my monitor", I used: "my monitor ; source run.sh"
Author
Owner

@swebs commented on GitHub (Feb 20, 2020):

@quanticle 's strategy above is great for local terminals, but as soon as you ssh to a different server it resets PS1 and you lose your title. So it would be really nice to be able to set a persistent label.

@swebs commented on GitHub (Feb 20, 2020): @quanticle 's strategy above is great for local terminals, but as soon as you ssh to a different server it resets PS1 and you lose your title. So it would be really nice to be able to set a persistent label.
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 20, 2020):

@quanticle 's strategy above is great for local terminals, but as soon as you ssh to a different server it resets PS1 and you lose your title. So it would be really nice to be able to set a persistent label.

To be fair, @quanticle's solution is even better (!) if you set it up on the remote server as well! That way, the title of the window can reflect which server you're currently accessing, and the shell can put in any dynamic information that would be germane to a remote session. That's something a local tab title override will never be able to accomplish, even if it were implemented perfectly.

@DHowett-MSFT commented on GitHub (Feb 20, 2020): > @quanticle 's strategy above is great for local terminals, but as soon as you ssh to a different server it resets PS1 and you lose your title. So it would be really nice to be able to set a persistent label. To be fair, @quanticle's solution is _even better (!)_ if you set it up on the remote server as well! That way, the title of the window can reflect _which server you're currently accessing_, and the shell can put in any dynamic information that would be germane to a remote session. That's something a local tab title override will _never_ be able to accomplish, even if it were implemented perfectly.
Author
Owner

@swebs commented on GitHub (Feb 20, 2020):

@DHowett-MSFT That would be true if you wanted the title to reflect "which server you are on", but not necessarily if you wanted the title to reflect something like a "task". So I might be using the same several servers, but for distinct tasks, and want to keep those tasks in different terminal tabs... and I want the name to persist as I switch back and forth between the servers in those tabs...

@swebs commented on GitHub (Feb 20, 2020): @DHowett-MSFT That would be true if you wanted the title to reflect "which server you are on", but not necessarily if you wanted the title to reflect something like a "task". So I might be using the same several servers, but for distinct tasks, and want to keep those tasks in different terminal tabs... and I want the name to persist as I switch back and forth between the servers in those tabs...
Author
Owner

@fanlix commented on GitHub (Feb 21, 2020):

Now, this is the last and only reason why i cant choose wt as main terminal tool on windows.
:(

@fanlix commented on GitHub (Feb 21, 2020): Now, this is the last and only reason why i cant choose wt as main terminal tool on windows. :(
Author
Owner

@davidhubyjincode commented on GitHub (Feb 21, 2020):

That's why Windows Terminal is not useful for me either, I end up with lots of tabs named node, and can't change them (even after attempting to change via the json, and using title and other solutions).

@davidhubyjincode commented on GitHub (Feb 21, 2020): That's why Windows Terminal is not useful for me either, I end up with lots of tabs named node, and can't change them (even after attempting to change via the json, and using `title` and other solutions).
Author
Owner

@zadjii-msft commented on GitHub (Feb 21, 2020):

I end up with lots of tabs named node,

Okay now that's a pretty good example of a scenario that needs this, and just setting the title form the shell won't fix. Thanks for the feedback!

@zadjii-msft commented on GitHub (Feb 21, 2020): > I end up with lots of tabs named node, Okay now that's a pretty good example of a scenario that _needs_ this, and just setting the title form the shell won't fix. Thanks for the feedback!
Author
Owner

@xairoo commented on GitHub (Mar 5, 2020):

This could help:

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

https://github.com/microsoft/terminal/issues/2304#issuecomment-528319270

@xairoo commented on GitHub (Mar 5, 2020): This could help: ` set PROMPT=$e]0;$p$e$p$g` https://github.com/microsoft/terminal/issues/2304#issuecomment-528319270
Author
Owner

@dylmye commented on GitHub (Mar 6, 2020):

To me this task is parity with cmder/etc. I often have multiple projects open in a bin folder or something similar so being able to apply custom labels would be helpful.

@dylmye commented on GitHub (Mar 6, 2020): To me this task is parity with cmder/etc. I often have multiple projects open in a `bin` folder or something similar so being able to apply custom labels would be helpful.
Author
Owner

@AlistairSymonds commented on GitHub (Mar 13, 2020):

Another use case would be for interacting over SSH to get names from linux envionment variables and combine it with the last part of the directory path, example tab name:
$PROJECTROOT $CONFIG src/path/to/dir
(and then trim off the start of the path, knowing my directory is somewhere under /user/username is less useful than knowing the end of the of the path)

@AlistairSymonds commented on GitHub (Mar 13, 2020): Another use case would be for interacting over SSH to get names from linux envionment variables and combine it with the last part of the directory path, example tab name: `$PROJECTROOT $CONFIG src/path/to/dir ` (and then trim off the start of the path, knowing my directory is somewhere under /user/username is less useful than knowing the end of the of the path)
Author
Owner

@mfeemster commented on GitHub (Mar 22, 2020):

This should also be configurable from the command line.

So when we are doing something like:

wt.exe -p "profile1"

We should be able to add an argument specifying the name of the tab, like:

wt.exe - "profile1" -name "name for tab 1"

This of course would work with every "new-tab" on the command line as well.

Thank you.

@mfeemster commented on GitHub (Mar 22, 2020): This should also be configurable from the command line. So when we are doing something like: wt.exe -p "profile1" We should be able to add an argument specifying the name of the tab, like: wt.exe - "profile1" -name "name for tab 1" This of course would work with every "new-tab" on the command line as well. Thank you.
Author
Owner

@zadjii-msft commented on GitHub (Mar 23, 2020):

@mfeemster thanks for the suggestion! I've added that to the mega list of work we're tracing for commandline args over in #4632:

  • Add support for -t,--title title to set the startingTitle of a new terminal session (add to terminal_parameters)
@zadjii-msft commented on GitHub (Mar 23, 2020): @mfeemster thanks for the suggestion! I've added that to the mega list of work we're tracing for commandline args over in #4632: > * [ ] Add support for `-t,--title title` to set the startingTitle of a new terminal session (add to `terminal_parameters`)
Author
Owner

@fanlix commented on GitHub (Mar 27, 2020):

by the way , if adding this feature, the window tab width should also be considered.
fixed width as 16-char wastes too much space for short-name, also hides important info for long-name.

I suggest :

  • the tab width should be 4-char to 24-char, auto adjust by tab name.
  • and remove the head/tail blank spaces.
  • if no icon is set, remove the space too.
  • add a config option to disable close-button "X" . only support right-click-menu closing.

putty-tab
save more room for real infomation. 😃

@fanlix commented on GitHub (Mar 27, 2020): by the way , if adding this feature, the window tab width should also be considered. fixed width as 16-char wastes too much space for short-name, also hides important info for long-name. I suggest : * the tab width should be 4-char to 24-char, auto adjust by tab name. * and remove the head/tail blank spaces. * if no icon is set, remove the space too. * add a config option to disable close-button "X" . only support right-click-menu closing. ![putty-tab](https://user-images.githubusercontent.com/987637/77721591-4829f980-7026-11ea-9846-faeaecd20c80.PNG) save more room for real infomation. 😃
Author
Owner

@zadjii-msft commented on GitHub (Mar 27, 2020):

@fanlix you'll be happy to know that your requests are largely already being tracked by

  • #597 - More tab sizing options beyond just equal and sizeToContent
  • #3327 - Theming options, including removing the 'X'
@zadjii-msft commented on GitHub (Mar 27, 2020): @fanlix you'll be happy to know that your requests are largely already being tracked by * #597 - More tab sizing options beyond just `equal` and `sizeToContent` * #3327 - Theming options, including removing the 'X'
Author
Owner

@fullenw1 commented on GitHub (Mar 29, 2020):

Note that you can also set the title from command line with title "new title" in cmd and $Host.UI.RawUI.WindowTitle = "new title" in powershell

This is only to rename the console.
But the aim of this original request is to rename tabs inside the console.
Please keep this in mind :)

@fullenw1 commented on GitHub (Mar 29, 2020): > Note that you can also set the title from command line with `title "new title"` in cmd and `$Host.UI.RawUI.WindowTitle = "new title"` in powershell This is only to rename the console. But the aim of this original request is to rename **tabs** inside the console. Please keep this in mind :)
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 31, 2020):

This is only to rename the console.
But the aim of this original request is to rename tabs inside the console.
Please keep this in mind :)

You should be made aware that changing the title of "the console", when the console is hosted in a tab, changes the title of the tab. 😄

@DHowett-MSFT commented on GitHub (Mar 31, 2020): > This is only to rename the console. > But the aim of this original request is to rename **tabs** inside the console. > Please keep this in mind :) You should be made aware that changing the title of "the console", when the console is hosted in a tab, _changes the title of the tab_. :smile:
Author
Owner

@fullenw1 commented on GitHub (Mar 31, 2020):

You should be made aware that changing the title of "the console", when the console is hosted in a tab, changes the title of the tab. 😄

Yes you are right. :-)
I didn't notice the way this was implemented because it also renames the name of the console...

In fact, the tab name on which you currently focus becomes the title of the console in the taskbar.
And as a consequence, if you work with several consoles in parallel (dedicated to several tasks with different remoting tab lists), the names of the consoles are not stable and you have to search again: "In which console is my tab?"

In ISE this is separated.
You have for the console name in the taskbar:

$Host.UI.RawUI.WindowTitle = "new title"

and for the tab names inside the console you have:

$psISE.CurrentPowerShellTab.DisplayName = "tab title"
@fullenw1 commented on GitHub (Mar 31, 2020): > You should be made aware that changing the title of "the console", when the console is hosted in a tab, _changes the title of the tab_. 😄 Yes you are right. :-) I didn't notice the way this was implemented because it also renames the name of the console... In fact, the tab name on which you currently focus becomes the title of the console in the taskbar. And as a consequence, if you work with several consoles in parallel (dedicated to several tasks with different remoting tab lists), the names of the consoles are not stable and you have to search again: "In which console is my tab?" In ISE this is separated. You have for the console name in the taskbar: ```powershell $Host.UI.RawUI.WindowTitle = "new title" ``` and for the tab names inside the console you have: ```powershell $psISE.CurrentPowerShellTab.DisplayName = "tab title" ```
Author
Owner

@patrioticcow commented on GitHub (Apr 28, 2020):

One problem with $Host.UI.RawUI.WindowTitle = "new title" is that if I run npm run dev, the tab title changes to npm

Cmder does it well.

@patrioticcow commented on GitHub (Apr 28, 2020): One problem with `$Host.UI.RawUI.WindowTitle = "new title"` is that if I run `npm run dev`, the tab title changes to `npm` [Cmder](https://cmder.net/) does it well.
Author
Owner

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

This is perfect idea for my productivity tracker wich use tab names. It would be awesome to automate it in the runtime. My work around:
(I get update every time I clear the console wich is alot 😝

## UI
    $pIcon = "💥"
    $tIcon = "😍"
      function trloc ($pth){
        $pwd -replace [regex]::Escape($HomeDir), $pth
      }

  # Comand line
    function prompt {
      (trloc($pIcon)) + "💁‍"
    }

  # Tab - Window - Title - Name as actual path (Shorted because I'am using ManicTime to track my productivity)
    function tabName { $Host.UI.RawUI.WindowTitle = trloc($tIcon) }
    function c { tabName; Clear-Host }
@AlesRFK commented on GitHub (May 13, 2020): This is perfect idea for my productivity tracker wich use tab names. It would be awesome to automate it in the runtime. My work around: (I get update every time I clear the console wich is alot 😝 ``` ## UI $pIcon = "💥" $tIcon = "😍" function trloc ($pth){ $pwd -replace [regex]::Escape($HomeDir), $pth } # Comand line function prompt { (trloc($pIcon)) + "💁‍" } # Tab - Window - Title - Name as actual path (Shorted because I'am using ManicTime to track my productivity) function tabName { $Host.UI.RawUI.WindowTitle = trloc($tIcon) } function c { tabName; Clear-Host } ```
Author
Owner

@robsonsobral commented on GitHub (May 14, 2020):

This is perfect idea for my productivity tracker wich use tab names. It would be awesome to automate it in the runtime. My work around:
(I get update every time I clear the console wich is alot 😝

## UI
    $pIcon = "💥"
    $tIcon = "😍"
      function trloc ($pth){
        $pwd -replace [regex]::Escape($HomeDir), $pth
      }

  # Comand line
    function prompt {
      (trloc($pIcon)) + "💁‍"
    }

  # Tab - Window - Title - Name as actual path (Shorted because I'am using ManicTime to track my productivity)
    function tabName { $Host.UI.RawUI.WindowTitle = trloc($tIcon) }
    function c { tabName; Clear-Host }

Hi. Please, which tracker do you use?

@robsonsobral commented on GitHub (May 14, 2020): > This is perfect idea for my productivity tracker wich use tab names. It would be awesome to automate it in the runtime. My work around: > (I get update every time I clear the console wich is alot 😝 > > ``` > ## UI > $pIcon = "💥" > $tIcon = "😍" > function trloc ($pth){ > $pwd -replace [regex]::Escape($HomeDir), $pth > } > > # Comand line > function prompt { > (trloc($pIcon)) + "💁‍" > } > > # Tab - Window - Title - Name as actual path (Shorted because I'am using ManicTime to track my productivity) > function tabName { $Host.UI.RawUI.WindowTitle = trloc($tIcon) } > function c { tabName; Clear-Host } > ``` Hi. Please, which tracker do you use?
Author
Owner

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

Hi. Please, which tracker do you use?

ManicTime
Now on linux is ActivityWatcher it is fine too, I hope that it will grow faster :)

@AlesRFK commented on GitHub (May 15, 2020): > Hi. Please, which tracker do you use? ManicTime Now on linux is ActivityWatcher it is fine too, I hope that it will grow faster :)
Author
Owner

@BearFather commented on GitHub (May 19, 2020):

The powershell only helps if that's what your running. When running ssh terminals with openssh, it would be nice to rename tabs to knew which host I'm on. It pickups up the first host you goto then after that that's what it display's, but if you change servers it doesn't update. I would love a r-click to rename option, or even some environment variable I could set it would pick up.

@BearFather commented on GitHub (May 19, 2020): The powershell only helps if that's what your running. When running ssh terminals with openssh, it would be nice to rename tabs to knew which host I'm on. It pickups up the first host you goto then after that that's what it display's, but if you change servers it doesn't update. I would love a r-click to rename option, or even some environment variable I could set it would pick up.
Author
Owner

@DHowett commented on GitHub (May 19, 2020):

I mean, that’s just something you could configure on those servers. :)

@DHowett commented on GitHub (May 19, 2020): I mean, that’s just something you could configure on those servers. :)
Author
Owner

@BearFather commented on GitHub (May 20, 2020):

You say that when we are talking over 1000 servers. I'm trying this out over xshell, and I have a bastion host that i jump from, and looking for an easy way to keep track of the server name. With xshell this done with scripting I use to set it internally.

Al tho I am playing with printf \033]0; and seems to be doing what I need.

@BearFather commented on GitHub (May 20, 2020): You say that when we are talking over 1000 servers. I'm trying this out over xshell, and I have a bastion host that i jump from, and looking for an easy way to keep track of the server name. With xshell this done with scripting I use to set it internally. Al tho I am playing with `printf \033]0;` and seems to be doing what I need.
Author
Owner

@ghost commented on GitHub (Jun 18, 2020):

:tada:This issue was addressed in #5775, which has now been successfully released as Windows Terminal Preview v1.1.1671.0.🎉

Handy links:

@ghost commented on GitHub (Jun 18, 2020): :tada:This issue was addressed in #5775, which has now been successfully released as `Windows Terminal Preview v1.1.1671.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.1.1671.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@dhavalhirdhav commented on GitHub (Jun 19, 2020):

Wow.. Congratulations team :D Apologies, I did not participate in thread much.. but I was following it closely. It gave me a great insights into how Microsoft plans features.. I have always trusted Microsoft.. but this process has given me kind of assurance that features are thought in details.. and with a quality in mind.. feature small as this one how it can be turned into a great feature is what this thread really teaches.

@dhavalhirdhav commented on GitHub (Jun 19, 2020): Wow.. Congratulations team :D Apologies, I did not participate in thread much.. but I was following it closely. It gave me a great insights into how Microsoft plans features.. I have always trusted Microsoft.. but this process has given me kind of assurance that features are thought in details.. and with a quality in mind.. feature small as this one how it can be turned into a great feature is what this thread really teaches.
Author
Owner

@skuda commented on GitHub (Jun 19, 2020):

Yes, congratulations to the team.

I miss one thing yet, being able to double click in tab to rename it, is that feature planned?

@skuda commented on GitHub (Jun 19, 2020): Yes, congratulations to the team. I miss one thing yet, being able to double click in tab to rename it, is that feature planned?
Author
Owner

@Inrego commented on GitHub (Sep 16, 2020):

Need to be able to set a key binding for tab rename (F2 by default would make sense?)

@Inrego commented on GitHub (Sep 16, 2020): Need to be able to set a key binding for tab rename (F2 by default would make sense?)
Author
Owner

@mfeemster commented on GitHub (Sep 16, 2020):

@Inrego You can just right click on the tab to rename it. KB shortcuts strike me as something needed for actions you perform often, so you don't want to use the mouse. But how often do you really rename a tab while working? I think the right-click menu is sufficient. Just my 2 cents.

@mfeemster commented on GitHub (Sep 16, 2020): @Inrego You can just right click on the tab to rename it. KB shortcuts strike me as something needed for actions you perform often, so you don't want to use the mouse. But how often do you really rename a tab while working? I think the right-click menu is sufficient. Just my 2 cents.
Author
Owner

@Inrego commented on GitHub (Sep 16, 2020):

@mfeemster a console application strikes me as something that shouldn't require a mouse to operate.

Besides that, I would like to automate naming tabs in my password manager when logging in to a server.
For now, I've gotten around it by using the command palette to open a new tab with the desired name. but it's not ideal.

@Inrego commented on GitHub (Sep 16, 2020): @mfeemster a console application strikes me as something that shouldn't require a mouse to operate. Besides that, I would like to automate naming tabs in my password manager when logging in to a server. For now, I've gotten around it by using the command palette to open a new tab with the desired name. but it's not ideal.
Author
Owner

@Inrego commented on GitHub (Sep 16, 2020):

There's KB shortcut to open a new tab. I'd argue that renaming a tab could be an action that is performed more often than opening a tab. Or there's also a KB shortcut to close all tabs. Also an action that is more rarely performed. Just because you rarely rename a tab, doesn't mean that you can assume that it's a rare action for everyone. What I'm trying to say, it shouldn't really be the reason to implement it or not, as it's very subjective and varies from person to person.

@Inrego commented on GitHub (Sep 16, 2020): There's KB shortcut to open a new tab. I'd argue that renaming a tab could be an action that is performed more often than opening a tab. Or there's also a KB shortcut to close all tabs. Also an action that is more rarely performed. Just because you rarely rename a tab, doesn't mean that you can assume that it's a rare action for everyone. What I'm trying to say, it shouldn't really be the reason to implement it or not, as it's very subjective and varies from person to person.
Author
Owner

@DHowett commented on GitHub (Sep 16, 2020):

Need to be able to set a key binding for tab rename (F2 by default would make sense?)

You can do this with a key binding for renameTab, but right now you can only hardcode a title. There's an open PR (#7462) that adds openTabRenamer. We need to circle back to that open PR.

@DHowett commented on GitHub (Sep 16, 2020): > Need to be able to set a key binding for tab rename (F2 by default would make sense?) You can do this with a key binding for `renameTab`, but right now you can only hardcode a title. There's an open PR (#7462) that adds `openTabRenamer`. We need to circle back to that open PR.
Author
Owner

@Inrego commented on GitHub (Sep 16, 2020):

That's exactly what I need, thanks. I'll follow that PR

@Inrego commented on GitHub (Sep 16, 2020): That's exactly what I need, thanks. I'll follow that PR
Author
Owner

@lukaseder commented on GitHub (Dec 3, 2020):

I'm seeing a few hacks for bash like printf \033]0; or echo -ne "\033]0;New Title\a" as documented here: https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title, but that only works for as long as the shell script making this call is running. The title reverts back to the path when the script terminates. Any ideas how to make it sticky?

@lukaseder commented on GitHub (Dec 3, 2020): I'm seeing a few hacks for bash like `printf \033]0;` or `echo -ne "\033]0;New Title\a"` as documented here: https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title, but that only works for as long as the shell script making this call is running. The title reverts back to the path when the script terminates. Any ideas how to make it sticky?
Author
Owner

@zadjii-msft commented on GitHub (Dec 3, 2020):

@lukaseder in 1.1 we added the ability to just rename the title from the UI -
image
That might be closer to what you're looking for.

IIRC bash sets the title in the prompt, defined as the variable PS1 in your .bashrc file. If using the UI doesn't work for you, you could remove that to prevent bash from resetting the title each time.

@zadjii-msft commented on GitHub (Dec 3, 2020): @lukaseder in 1.1 we added the ability to just rename the title from the UI - ![image](https://user-images.githubusercontent.com/18356694/101002079-8668a880-3525-11eb-865f-209d77b85fcf.png) That might be closer to what you're looking for. IIRC `bash` sets the title in the prompt, defined as the variable `PS1` in your `.bashrc` file. If using the UI doesn't work for you, you could remove that to prevent bash from resetting the title each time.
Author
Owner

@lukaseder commented on GitHub (Dec 3, 2020):

@zadjii-msft I know, I'm using that all the time, but since the tabs can't be reopened from a previous session (see https://github.com/microsoft/terminal/issues/961), I was going to work around this by scripting my usual 10 tabs into .sh scripts.

IIRC bash sets the title in the prompt, defined as the variable PS1 in your .bashrc file. If using the UI doesn't work for you, you could remove that to prevent bash from resetting the title each time.

That did the trick, thank you! PS1 was set to:

\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$

setting it to this in .bashrc solved it for me:

export PS1="\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ "
@lukaseder commented on GitHub (Dec 3, 2020): @zadjii-msft I know, I'm using that all the time, but since the tabs can't be reopened from a previous session (see https://github.com/microsoft/terminal/issues/961), I was going to work around this by scripting my usual 10 tabs into `.sh` scripts. > IIRC `bash` sets the title in the prompt, defined as the variable `PS1` in your `.bashrc` file. If using the UI doesn't work for you, you could remove that to prevent bash from resetting the title each time. That did the trick, thank you! PS1 was set to: ``` \[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ``` setting it to this in `.bashrc` solved it for me: ``` export PS1="\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ " ```
Author
Owner

@palenshus commented on GitHub (Feb 2, 2021):

Note that you can also set the title from command line with title "new title" in cmd and $Host.UI.RawUI.WindowTitle = "new title" in powershell

Very helpful! I added a function to my Powershell Profile to let me set it more easily:

function Set-Title {
    param(
        [string]
        $title
    )
    $Host.UI.RawUI.WindowTitle = $title   
}

Good tip! If you use powershell and want your title to reflect the current directory context, you can set it in your global:prompt function. For example, I always want it to reflect the current repo's root dir (if I'm in a repo):

  function global:prompt
  {
      $gitDir = git rev-parse --show-toplevel 2>$null
      Set-Title ([System.IO.Path]::GetFileName($gitDir))
  }
@palenshus commented on GitHub (Feb 2, 2021): > > Note that you can also set the title from command line with `title "new title"` in cmd and `$Host.UI.RawUI.WindowTitle = "new title"` in powershell > > Very helpful! I added a function to my Powershell Profile to let me set it more easily: > > ``` > function Set-Title { > param( > [string] > $title > ) > $Host.UI.RawUI.WindowTitle = $title > } > ``` Good tip! If you use powershell and want your title to reflect the current directory context, you can set it in your global:prompt function. For example, I always want it to reflect the current repo's root dir (if I'm in a repo): function global:prompt { $gitDir = git rev-parse --show-toplevel 2>$null Set-Title ([System.IO.Path]::GetFileName($gitDir)) }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1440