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

Feature Request: ability to set title and colour of a tab #2509

Closed
markpapadakis opened this issue Oct 27, 2024 · 35 comments · Fixed by #4217
Closed

Feature Request: ability to set title and colour of a tab #2509

markpapadakis opened this issue Oct 27, 2024 · 35 comments · Fixed by #4217
Milestone

Comments

@markpapadakis
Copy link

This is a really useful feature of iTerm2; I use different tabs for various projects and such, and being able to name them/set their title, and doubly so, being able to set a color, makes it a lot easier to switch to the right tabs and work with a tabs-based workflow.

Image

Image

Image

@mitchellh
Copy link
Contributor

mitchellh commented Oct 27, 2024

Since we use a native tab bar, I'm not sure what our ability is to color the tabs individually...

@qwerasd205 do you happen to know off the top of your head?

@tristan957 do you know what this is like on GTK/libadw off the top of your head?

Additional question: when you set the title on iTerm, does it just ignore program requests to set the title? I assume so and will verify but if you know that'd be useful.

@markpapadakis
Copy link
Author

@mitchellh yes, it does; the title never changes unless you change it yourself again.

@markpapadakis
Copy link
Author

markpapadakis commented Oct 27, 2024

Speaking of tabs functionality, "Close tabs to the Right" is also very handy (Close Other Tabs as well)

@jcollie
Copy link
Member

jcollie commented Oct 27, 2024

Coloring individual tabs on GTK/libadwaita should be pretty easy with the use of the runtime CSS and adding unique CSS class names to each tab. The difficult thing I think will be getting the UI/UX right. On iTerm2 is this functionality invoked by right-clicking on the tab, or by right clicking on the surface? If it's the surface it would be easy enough to add a menu item to our existing context menu.

Image

@qwerasd205
Copy link
Member

I believe coloring individual tabs for macOS should be relatively straightforward since we're already hacking the view hierarchy as is. My instinct would be to navigate up from the tab accessory view (which we use to display the key equivalents) to the tab container view and set the background on that. As a side note: I had the thought that automatically coloring tabs by the background color of the focused surface in that tab would be cool.

@markpapadakis
Copy link
Author

On iTerm2 is this functionality invoked by right-clicking on the tab, or by right clicking on the surface? If it's the surface it would be easy enough to add a menu item to our existing context menu.

You get the tab configuration popup/view when you right-click on the tab, not on the "surface" (iTerm2).

When you right-click on the "surface"/content view, you get
Image

@jcollie
Copy link
Member

jcollie commented Oct 27, 2024

After doing a little digging, setting the CSS for the tab bar title isn't going to be straightforward in GTK/libadwaita. Neither would be assigning a context menu to the tab bar.

@tristan957
Copy link
Member

After doing a little digging, setting the CSS for the tab bar title isn't going to be straightforward in GTK/libadwaita. Neither would be assigning a context menu to the tab bar.

I went ahead and asked in the libadwaita matrix room

@neurocyte
Copy link
Contributor

neurocyte commented Oct 28, 2024

On a related note, I have opened PR #2514 to add support for app runtimes to set their colors dynamically based on the current terminal application. I also have a work-in-progress PR #2515 to go along with it that adds support to apprt/gtk to dynmically change the titlebar coloring to match.

@jcollie
Copy link
Member

jcollie commented Oct 28, 2024

After doing a little digging, setting the CSS for the tab bar title isn't going to be straightforward in GTK/libadwaita. Neither would be assigning a context menu to the tab bar.

I went ahead and asked in the libadwaita matrix room

Thanks!

@tristan957
Copy link
Member

tristan957 commented Oct 28, 2024

It is not possible, so we will not implement this in the GTK/libadwaita runtime. I wonder if there is some other way we could expose this metaphor for the runtime.

@mitchellh
Copy link
Contributor

It is not possible, so we will not implement this in the GTK/libadwaita runtime.

Thanks for looking into it. We can at least point to the gtk/libadw teams as a source of this when we're asked about it. I think making this macOS only is fine.

@tristan957
Copy link
Member

I wonder if tab groups would be a better feature vs colored tabs?

@jcollie
Copy link
Member

jcollie commented Oct 28, 2024

It is not possible, so we will not implement this in the GTK/libadwaita runtime. I wonder if there is some other way we could expose this metaphor for the runtime.

Oof. That's too bad. Maybe using https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/method.TabPage.set_icon.html to set a icon that's a color block?

@mitchellh
Copy link
Contributor

It's a neat idea. I think we can maybe spin it out into a separate discussion eventually but I think maybe being able to specify an emoji icon instead to categorize.

@jcollie
Copy link
Member

jcollie commented Oct 28, 2024

Also, looks like a context menu when you right click on the tab should be possible: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.set_menu_model.html

@skatkov
Copy link

skatkov commented Oct 29, 2024

I'll vote for the idea of renaming a tab. Never used coloring, so personally don't find it useful.

I may run multiple different web services on a single machine and all the tab names represent commands that I used to launch those. So I can easily end up with three rails server tabs without any way to distinguish which service is running in those (and I can easily forget after some time).

@jcollie
Copy link
Member

jcollie commented Oct 29, 2024

Just added #2529 which adds the ability to right-click in a GTK/libadwaita tab header and get a context menu.

@xiaket
Copy link

xiaket commented Dec 26, 2024

I assume this goes without saying, but having this as an action that can be triggered by a keybind would be tremendously helpful.

@edrozenberg
Copy link

edrozenberg commented Dec 28, 2024

Related but a bit different, I'm hoping to be able to use a generic fixed title for windows ("Ghostty"), but allow the title of each tab to automatically reflect the activity/contents. For ex. a window would be named "Ghostty", but each tab would have a different dynamic name based on which server I've ssh'd to in that tab. This is currently possible in the MacOS Terminal.app for example:

Terminal.app title for windows:
Image

Terminal.app title for tabs:
Image

I noticed in this issue #1026 the following:

mitchellh (Dec 8, 2023)
Is the tab one documented anywhere? I haven't seen that sequence before. This would be an issue on macOS, our tabs ARE windows so there is no way to set a separate tab title from window title. iTerm can do it because they use a custom tab system that aren't native tabs, so they can differentiate.

That's too bad if that's the case, Apple's Terminal.app CAN do separate window vs. tab titles, but maybe they're using some private code/api as they often do.

@felixkreuk
Copy link

maybe i missed it in the docs, but is there an option to use escape codes to set the tab title? similarly to:
https://iterm2.com/documentation-escape-codes.html

@awhitford
Copy link

Should this issue be split into 2 issues:

  1. Ability to set the Tab Title
  2. Ability to set the Tab Color

One may be tricker than the other. I'm personally more concerned about the title.

@jlimas
Copy link

jlimas commented Dec 30, 2024

+1 on the tab title rename, I think it's the only feature missing for me, awesome tool 🫰

@kbd
Copy link

kbd commented Dec 31, 2024

FWIW here's a current example of how I use kitty's tabs and its remote control to make it easy to find the tab I'm looking for:

Image

I use Peacock to set the color of a vscode window per directory, then direnv to look for the settings.json and if there is one, I parse the json and set some env vars that my prompt picks up to set kitty's tab color and then I set the window title in my zsh precmd based on the path (using zsh's hashed directories to make them short).

Edit: plus, keyboard shortcuts to move and navigate tabs. The hash and index number in the active kitty tab comes from here.

@SachaG
Copy link

SachaG commented Jan 2, 2025

Image

Personally I use emojis as tab titles and I find it helps a lot when dealing with multiple sub-folders in a big monorepo.

@faceless2
Copy link

Reading the comments here I understand it may be difficult to do for a tab, but if it would be easier to set the theme for an individual window (say by selecting one of several from the menu) that would still be useful.

@pandalec
Copy link

pandalec commented Jan 8, 2025

Would be nice if I could do this via bash, like in kitty:

kitty @ set-window-title --match id:$KITTY_WINDOW_ID "New Title"

@o1lo01ol1o
Copy link

+1 for per tab theme assignment

@JulyWitch
Copy link

JulyWitch commented Jan 25, 2025

+1 for tab titles
It would be really cool. I'm also coming from ITerm2 like the opener, It helps to make sense out of tab titles

It works by double clicking on title in ITerm2

@pandalec
Copy link

tabname="Tab Title"
echo -ne "\033]0;$tabname\007"

Sets the title as a workaround

@benelori
Copy link

Tab titles renaming is also the only thing missing for me as well. When I'm especially busy, I fallback to Gnome terminal for this

@David-Andrino
Copy link

+1 for tab titles, allowing for a keybind would also be great.

tabname="Tab Title"
echo -ne "\033]0;$tabname\007"

Sets the title as a workaround

I think this is only a temporal fix, other programs (neovim, starship, etc) usually set a title like this too, so it will be overridden.

@pluiedev
Copy link
Member

pluiedev commented Jan 26, 2025

Please avoid adding comments that mostly only repeat what has already been said before. We get a notification (maybe even an email) every time someone adds a comment, so please communicate your support by reacting with 👍🏼 instead

@mitchellh
Copy link
Contributor

#4217 adds the ability to change tab titles (any titles, really).

I'm going to close this despite not being able to set tab colors yet. That's more of a secondary request still being discussed and the major request was for title changing specifically on macOS.

GTK support extracted to issue #5769

@karlhorky
Copy link

karlhorky commented Feb 15, 2025

@mitchellh thanks! Cool to have UI options for this.

What's the recommended way to programmatically set the tab title in Ghostty? eg. using the zsh precmd and preexec hook functions as such:

# Disable auto-setting terminal title.
DISABLE_AUTO_TITLE="true"
function precmd () {
  echo -ne "\033]0;$(print -rD $PWD)\007"
}
precmd

function preexec () {
  print -Pn "\e]0;🚀 $(print -rD $PWD) $1 🚀\a"
}

Or is this not possible yet?


Edit: Oh, it appears that it's maybe required to disable Ghostty's built-in shell integration using shell-integration-features = no-title?

~/Library/Application Support/com.mitchellh.ghostty/config

# Disable Ghostty built-in tab title shell integration
# https://ghostty.org/docs/config/reference#shell-integration-features
shell-integration-features = no-title

This seems to work for now:

Screen.Recording.2025-02-15.at.17.36.47.mov

zsh config:

~/.zshrc

# Disable auto-setting terminal title.
DISABLE_AUTO_TITLE="true"
function precmd () {
  echo -ne "\033]0;Custom title: $(print -rD $PWD)\007"
}
precmd

function preexec () {
  print -Pn "\e]0;🚀 $(print -rD $PWD) $1 🚀\a"
}

Also added to Command Line Tricks here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.