Terminal: Ability to rename Tab title at runtime

Created on 31 May 2019  ·  56Comments  ·  Source: microsoft/terminal

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

Area-User Interface Issue-Feature Product-Terminal Resolution-Fix-Committed

Most helpful comment

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

All 56 comments

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.

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.

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.

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.

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

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 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.

@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:

@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!

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

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

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

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   
}

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.

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 just use a function or alias like tvsbrent's comment above

@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.

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

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

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\]> "
}

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.

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.

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.

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

@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.

@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 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...

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

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).

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!

This could help:

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

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

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.

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)

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 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)

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 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'

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 :)

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:

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"

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.

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 }

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?

Hi. Please, which tracker do you use?

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

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.

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

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.

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

Handy links:

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.

Yes, congratulations to the team.

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

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

@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 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.

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.

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrmlnc picture mrmlnc  ·  3Comments

miniksa picture miniksa  ·  3Comments

waf picture waf  ·  3Comments

mrmlnc picture mrmlnc  ·  3Comments

zadjii-msft picture zadjii-msft  ·  3Comments