Support runtime variables in the custom user title #1746

Open
opened 2026-01-30 22:35:23 +00:00 by claunia · 7 comments
Owner

Originally created by @zadjii-msft on GitHub (Jun 19, 2019).

The user should be able to embed certain terminal-specific variables in their custom title, that will be updated at runtime.

Something like:

{
    "title":"{numberOfPanes} - Powershell"
}

Would then include the number of panes in the tab title text we display, like so:

5 - Powershell

  • What syntax do we chose for these custom variables?
  • What variables should we include?
    • We should probably avoid any that'd be better served by a shell setting the title
    • #2396 We should be able to conditionally put "Administrator" in the title
    • #13241 - similarly, with the shield emoji
    • #18890 - the window name
  • Do we need to register change event handlers for each variable that they've put in the title? How do we handle that?
  • Should we enable conditional elements in the string? e.g. "{isAdmin?\"Admin\":\"\"} - {title}" to get "Admin - cmd.exe"
    • Another example - "{name} [{numberOfPanes<10?numberOfPanes : \"9+\"}]" for "Powershell [2]" or "Powershell [9+]"
    • Another example - how would we get "Powershell" for 1 pane, but then "Powershell [+1]" for 2 panes? How would we encode the entire [+{numberOfPanes}] bit should be conditional on there being more than one pane? Could we combine this with the above case, and have nested conditionals?
      • Does all of this basically mean embedding an entire scripting language into the tabTitle?
  • Request: "Tab title" text resolves environment variables #10144
  • #9929, Unable to open new tab when the only open tab is settings (#13506)

This is obviously related to #608, but this is certainly out of scope for v1.0. #608 is just setting a simple title string to override the terminal's, this is setting a dynamic title.


Something we probably need to comport with #4183

Are we setting the title per-pane or per window? That affects how we structure the variables

Originally created by @zadjii-msft on GitHub (Jun 19, 2019). The user should be able to embed certain terminal-specific variables in their custom title, that will be updated at runtime. Something like: ```json { "title":"{numberOfPanes} - Powershell" } ``` Would then include the number of panes in the tab title text we display, like so: > 5 - Powershell * [ ] What syntax do we chose for these custom variables? * [ ] What variables should we include? - We should probably avoid any that'd be better served by a shell setting the title - #2396 We should be able to conditionally put "Administrator" in the title - #13241 - similarly, with the shield emoji - #18890 - the _window_ name * [ ] Do we need to register change event handlers for each variable that they've put in the title? How do we handle that? * [ ] Should we enable conditional elements in the string? e.g. `"{isAdmin?\"Admin\":\"\"} - {title}"` to get "Admin - cmd.exe" - Another example - `"{name} [{numberOfPanes<10?numberOfPanes : \"9+\"}]"` for "Powershell [2]" or "Powershell [9+]" - Another example - how would we get "Powershell" for 1 pane, but then "Powershell [+1]" for 2 panes? How would we encode the entire `[+{numberOfPanes}]` bit should be conditional on there being _more than one pane_? Could we combine this with the above case, and have nested conditionals? - Does all of this basically mean embedding an entire scripting language into the tabTitle? * [ ] Request: "Tab title" text resolves environment variables #10144 * [ ] #9929, #13506 This is _obviously_ related to #608, but this is certainly out of scope for v1.0. #608 is just setting a _simple_ title string to override the terminal's, this is setting a _dynamic_ title. ----- Something we probably need to comport with #4183 Are we setting the title per-pane or per window? That affects how we structure the variables
claunia added the Issue-FeatureHelp WantedProduct-TerminalArea-UserInterface labels 2026-01-30 22:35:23 +00:00
Author
Owner

@Jaykul commented on GitHub (Jun 22, 2019):

Do we really want that? Would we then have to update it constantly?

What if users just set the title themselves using VT sequences, and we made information like that available in environment variables or via VT query responses ...

@Jaykul commented on GitHub (Jun 22, 2019): Do we really want that? Would we then have to update it _constantly_? What if users just set the title themselves using VT sequences, and we made information like that available in environment variables or via VT query responses ...
Author
Owner

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

@Jaykul if I could have convinced people that the VT title was all they needed, we wouldn’t have had a forty-comment-long discussion in #608 and a followup deliverable :(
For some reason, which is as yet non-obvious to me, people want a title that isn’t the one set by their app.

The moment they get that, they’ll complain that they’re not seeing their application title :p

@DHowett-MSFT commented on GitHub (Jun 22, 2019): @Jaykul if I could have convinced people that the VT title was all they needed, we wouldn’t have had a forty-comment-long discussion in #608 and a followup deliverable :( For some reason, which is as yet non-obvious to me, people want a title that isn’t the one set by their app. The moment they get that, they’ll complain that they’re not seeing their application title :p
Author
Owner

@Jaykul commented on GitHub (Jun 22, 2019):

Yeah, I'll help fight it there too 🙄 what we need is education, not configuration.
We have plenty of capability to set it however we want, already.

@Jaykul commented on GitHub (Jun 22, 2019): Yeah, I'll help fight it there too 🙄 what we need is education, not configuration. We have plenty of capability to set it however we want, already.
Author
Owner

@DJackman123 commented on GitHub (Aug 5, 2019):

The reason I want this feature is not because I don't know how to set the title from the console, but because the scripts that I run as part of my job keep changing the title. What's worse is these scripts don't know anything about tabbed console windows, so they set the title to something super long. I want much more control over the tab titles, regardless of what scripts try to do to them. When I use Terminal I will have many tabs open at a time, and I'd like each of the tab titles to be very concise so I can see as many tabs as possible without scrolling. This means being able to strip the "Administrator:" prefix to all of the tabs. (I'd much rather have the administrator status represented by the tab color or something else that doesn't take up valuable space in the tabs.) It would also be most helpful for the tab title to also tell me which tab number it is so I can quickly know which hotkey to use to change to that tab. The ideal would be for Terminal to let me provide a regular expression for extracting the most important parts of what the console app wants the title to be so I can have it display the most important information in the actual title, including whether or not the script I started in that tab is still running (to be represented in the tab by a single character, not a long string of text set by the script).
Is this something that's already possible with VT title? If more education is all that I need, please help me find the documentation for how to do this.

@DJackman123 commented on GitHub (Aug 5, 2019): The reason I want this feature is not because I don't know how to set the title from the console, but because the scripts that I run as part of my job keep changing the title. What's worse is these scripts don't know anything about tabbed console windows, so they set the title to something super long. I want much more control over the tab titles, regardless of what scripts try to do to them. When I use Terminal I will have many tabs open at a time, and I'd like each of the tab titles to be very concise so I can see as many tabs as possible without scrolling. This means being able to strip the "Administrator:" prefix to all of the tabs. (I'd much rather have the administrator status represented by the tab color or something else that doesn't take up valuable space in the tabs.) It would also be most helpful for the tab title to also tell me which tab number it is so I can quickly know which hotkey to use to change to that tab. The ideal would be for Terminal to let me provide a regular expression for extracting the most important parts of what the console app wants the title to be so I can have it display the most important information in the actual title, including whether or not the script I started in that tab is still running (to be represented in the tab by a single character, not a long string of text set by the script). Is this something that's already possible with VT title? If more education is all that I need, please help me find the documentation for how to do this.
Author
Owner

@Jaykul commented on GitHub (Aug 5, 2019):

Well, the VT title just lets you set the title to whatever text you want. Unfortunately, it does not differentiate between "you" and "scripts that you run", and it doesn't (yet) have any extensibility you can configure.

I agree 100% with the desire to have the tab number prefix on the (first 10) tabs, so it's easy to switch via hotkeys without counting -- and that's basically impossible for the shell/scripts to do.

It might even be nice to be able to force a titlePrefix from the profile before whatever scripts try to set. That is, not just the tab number, but a word that represents the shell to me: "bash", "pwsh", "ubuntu", "wsl", "cmd", "PS7", etc. That way I could have tabs like:

  • 1️⃣ PS6: Deploying Az Templates [Step 2 of 132]
  • 2️⃣ CMD: C:\Windows\
  • 3️⃣ WSL: sh top*
  • 4️⃣ PS7: ~\Projects\Terminal
  • ... etc.

I wouldn't fight the idea of providing a regex to let you configure that, like: "(.*)", "{number} PS6: $1" or even "(?:Administrator|Admin)\s+(.*)", "{number} PS6: $1" or whatever 😁. After all (until Terminal has a way to launch "Admin" tabs side-by-side with non-admin tabs) it is totally redundant to have "Administrator" on every tab...

We'll definitely need a few other features for those prone to lots of tabs like

  • An option to shorten tabs to force all tabs on screen at once (down to a minimum tab width), regardless of title length
    • Mouse over tool tips of the full title
  • A list of the active tabs (maybe in the current new-tab menu)
    • The list could show up (like VS Code's does) on Ctrl+Tab (or only show up when there are tabs that aren't visible because of length)
@Jaykul commented on GitHub (Aug 5, 2019): Well, the VT title just lets you set the title to whatever text you want. Unfortunately, it _does not_ differentiate between "you" and "scripts that you run", and it doesn't (yet) have any extensibility you can configure. I agree 100% with the desire to have the tab number prefix on the (first 10) tabs, so it's easy to switch via hotkeys without counting -- and that's basically impossible for the shell/scripts to do. It might even be nice to be able to force a **titlePrefix** from the profile before whatever scripts try to set. That is, not just the tab number, but a word that represents the shell to me: "bash", "pwsh", "ubuntu", "wsl", "cmd", "PS7", etc. That way I could have tabs like: - 1️⃣ PS6: Deploying Az Templates [Step 2 of 132] - 2️⃣ CMD: C:\Windows\ - 3️⃣ WSL: sh top* - 4️⃣ PS7: ~\Projects\Terminal - ... etc. I wouldn't fight the idea of providing a regex to let you configure that, like: `"(.*)", "{number} PS6: $1"` or even `"(?:Administrator|Admin)\s+(.*)", "{number} PS6: $1"` or whatever 😁. After all (until Terminal has a way to launch "Admin" tabs side-by-side with non-admin tabs) it **is** totally redundant to have "Administrator" on every tab... We'll definitely need a few other features for those prone to lots of tabs like - An option to shorten tabs to force all tabs on screen at once (down to a minimum tab width), regardless of title length - Mouse over tool tips of the full title - A list of the active tabs (maybe in the current new-tab menu) - The list could show up (like VS Code's does) on Ctrl+Tab (or only show up when there are tabs that aren't visible because of length)
Author
Owner

@lzybkr commented on GitHub (Nov 26, 2019):

I'm all for a static but configurable title. I put the shell PID and an glyph for elevated sessions, otherwise the profile name is enough - assuming the auto-detect profiles for PowerShell and WSL could add a version.

image

@lzybkr commented on GitHub (Nov 26, 2019): I'm all for a static but configurable title. I put the shell PID and an glyph for elevated sessions, otherwise the profile name is enough - assuming the auto-detect profiles for PowerShell and WSL could add a version. ![image](https://user-images.githubusercontent.com/2148248/69663185-97d9c380-103a-11ea-8b05-ea834ad26a60.png)
Author
Owner

@zadjii-msft commented on GitHub (Feb 4, 2022):

VS Code's implementation, for reference: https://code.visualstudio.com/updates/v1_61#_custom-title-and-description

@zadjii-msft commented on GitHub (Feb 4, 2022): VS Code's implementation, for reference: https://code.visualstudio.com/updates/v1_61#_custom-title-and-description
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1746