Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to rename Tab title at runtime #1079

Closed
dhavalhirdhav opened this issue May 31, 2019 · 60 comments · Fixed by #5775
Closed

Ability to rename Tab title at runtime #1079

dhavalhirdhav opened this issue May 31, 2019 · 60 comments · Fixed by #5775
Assignees
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@dhavalhirdhav
Copy link

dhavalhirdhav commented May 31, 2019

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

@dhavalhirdhav dhavalhirdhav added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 31, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 31, 2019
@mdtauk
Copy link

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

@DHowett-MSFT
Copy link
Contributor

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.

@dhavalhirdhav
Copy link
Author

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.

@zadjii-msft
Copy link
Member

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.

@mdtauk
Copy link

mdtauk commented 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

@zadjii-msft
Copy link
Member

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 zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels May 31, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 31, 2019
@zadjii-msft zadjii-msft added this to the Backlog milestone May 31, 2019
@dhavalhirdhav
Copy link
Author

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

@DHowett-MSFT
Copy link
Contributor

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

@carlos-zamora
Copy link
Member

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

@dhavalhirdhav
Copy link
Author

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

@DHowett-MSFT DHowett-MSFT added this to Spec Needed ❓ in Specification Tracker via automation May 31, 2019
@phuclv90
Copy link

phuclv90 commented 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

@DHowett-MSFT
Copy link
Contributor

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

@DHowett-MSFT DHowett-MSFT added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 3, 2019
@DHowett-MSFT DHowett-MSFT removed this from Spec Needed ❓ in Specification Tracker Jun 14, 2019
@tvsbrent
Copy link

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   
}

@zadjii-msft zadjii-msft removed the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Aug 12, 2019
@AlennGK
Copy link

AlennGK commented 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 }

@robsonsobral
Copy link

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?

@AlennGK
Copy link

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

@BearFather
Copy link

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.

@DHowett
Copy link
Member

DHowett commented May 19, 2020

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

@BearFather
Copy link

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.

@ghost ghost closed this as completed in #5775 May 28, 2020
@ghost ghost removed the In-PR This issue has a related PR label May 28, 2020
ghost pushed a commit that referenced this issue May 28, 2020
## Summary of the Pull Request

Adds support for setting, from the UI, a runtime override for the tab title text. The user can use this to effectively "rename" a tab.

If set, the tab will _always_ use the runtime override string. If the user has multiple panes with different titles in a pane, then the tab's override text will be used _regardless_ of which pane was focused when the tab was renamed.

The override text can be removed by just deleting the entire contents of the box. Then, the tab will revert to using the terminal's usual title. 

## References
* Wouldn't be possible without the context menu from #3789
* Focus doesn't return to the active terminal after hitting <kbd>enter</kbd>/<kbd>esc</kbd>, but that's tracked by #5750 

## PR Checklist
* [x] Closes #1079
* [x] I work here
* [ ] Tests added/passed
* [ ] Requires documentation to be updated

## TODO
* [x] `Tab::SetTabText` might be able to be greatly simplified/removed?
* [x] I'm _pretty sure_ if they set an override title, we won't bubble that up to set the window title.
* [x] I'm unsure how this behaves when the terminal's title changes _while_ the TextBox is visible. I don't think it should change the current contents of the box, but it might currently.
* [ ] **for discussion**: If the user doesn't actually change the text of the tab, then we probably shouldn't set the override text, right? 
  - EX: if they open the box and the text is "cmd", and immediately hit <kbd>enter</kbd>, then run `title foo`, should the text change to "foo" or stay "cmd"?

## Detailed Description of the Pull Request / Additional comments
![image](https://user-images.githubusercontent.com/18356694/81230615-713f9180-8fb7-11ea-8945-6681eec02a4f.png)
![image](https://user-images.githubusercontent.com/18356694/81230640-7ac8f980-8fb7-11ea-9e6b-22f0e0ed128a.png)
![image](https://user-images.githubusercontent.com/18356694/81230665-86b4bb80-8fb7-11ea-90f0-16d4ffb60d89.png)
![image](https://user-images.githubusercontent.com/18356694/81230686-9207e700-8fb7-11ea-94a9-f3f5a59be139.png)
![image](https://user-images.githubusercontent.com/18356694/81230732-a350f380-8fb7-11ea-9901-6dd4f36154f1.png)
![image](https://user-images.githubusercontent.com/18356694/81230746-a8ae3e00-8fb7-11ea-94fa-d2578f9241a7.png)
![image](https://user-images.githubusercontent.com/18356694/81230787-bc59a480-8fb7-11ea-8edf-2bd7fad343fc.png)
![image](https://user-images.githubusercontent.com/18356694/81230851-dc896380-8fb7-11ea-98c1-918b943543e4.png)
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label May 28, 2020
@ghost
Copy link

ghost commented Jun 18, 2020

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

Handy links:

@dhavalhirdhav
Copy link
Author

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.

@skuda
Copy link

skuda commented 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?

@Inrego
Copy link

Inrego commented Sep 16, 2020

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

@mfeemster
Copy link

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

@Inrego
Copy link

Inrego commented 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
Copy link

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

@DHowett
Copy link
Member

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

@Inrego
Copy link

Inrego commented Sep 16, 2020

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

@lukaseder
Copy link

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?

@zadjii-msft
Copy link
Member

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

@lukaseder
Copy link

lukaseder commented 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 #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$ "

@palenshus
Copy link

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.