Skip to content

Conversation

@aswinmprabhu
Copy link
Contributor

Tries to resolve #2509 partially by enabling tab title renaming feature for MacOS.

  • Used the existing set_title action
  • Added the set_title action to Bindings so that a keybind can be set for this feature (defaulted this to cmd+i -- same as iTerm2)
  • 3 ways to trigger this feature: "Set Title" option in the right-click menu for the window, "Set Title" option in the "View" menu in the title bar, and the keybind (cmd+i default)
  • Prevented esc sequences from the different programs from resetting the tab title once it is set manually using a new state var called titleSetManually in the SurfaceView
  • The input box is a basic native macos dialog with "OK" and "Cancel". Leaving the title text box empty resets the title to automatic / from the title property in the config

Demo:

Screenshare.-.2025-01-01.12_59_47.AM.1.mp4

Need some feedback. Thanks!

@qwerasd205
Copy link
Member

Haven't reviewed the code, but the demo looks good. I'd prefer if the UI were in a popover that drops down from the tab title, but that can come later, this is fine as it is.

@francescarpi
Copy link
Contributor

I love this feature! It would also be nice to be able to change the title by double-clicking the tab title. This could be addressed in a separate PR, depending on the difficulty.
Thanks!

@mitchellh
Copy link
Contributor

Sorry for the delay! Great work with this. I made some modifications that I felt were important:

  • SurfaceView keeps track of the last title libghostty sent, so when we reset the title we can immediately set it to the correct value. Previously, it waited for the next.
  • The above also removes the reload_config which we shouldn't ever call unless the config actually wants to be reloaded.
  • I changed the binding action to change_title_prompt
  • I also made an apprt action this can trigger

@jcollie
Copy link
Member

jcollie commented Feb 14, 2025

I'm going to bikeshed this a bit but what's the rationale for some things being called set_title_prompt and some things being called change_title_prompt. Also why is "prompt" part of the verb anyway? We're not changing a prompt. IMHO, there should be a keybind called "prompt_for_tab_title" that pops up a dialog box, and an apprt action called "set_tab_title" that performs the change.

mitchellh
mitchellh previously approved these changes Feb 14, 2025
@mitchellh
Copy link
Contributor

mitchellh commented Feb 14, 2025

I'm going to bikeshed this a bit but what's the rationale for some things being called set_title_prompt and some things being called change_title_prompt

Yeah I will unify this.

Also why is "prompt" part of the verb anyway?

Because the user is being prompted

IMHO, there should be a keybind called "prompt_for_tab_title" that pops up a dialog box, and an apprt action called "set_tab_title" that performs the change.

Note this is actually unrelated to tabs. These are surface titles.

@jcollie
Copy link
Member

jcollie commented Feb 14, 2025

Because the user is being prompted

Then it should be prompt... and not set_...

@mitchellh
Copy link
Contributor

Then it should be prompt... and not set_...

I'm good with this

@mitchellh
Copy link
Contributor

Renamed. The macOS details are still named changeTitle and so on since that aligns with the menu item and makes more sense. It's more confusing at the core config level to use "change" because I could foresee bindings to change it to a preset value vs prompting. In a GUI prompting is implied in various ways, such as with the ellipses on the menu item, being a GUI interaction, etc.

@mitchellh mitchellh merged commit 1121ea9 into ghostty-org:main Feb 14, 2025
29 checks passed
@github-actions github-actions bot added this to the 1.2.0 milestone Feb 14, 2025
Copy link

@mdznr mdznr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ellipsis character should be used in menu items like these

https://support.apple.com/guide/applestyleguide/e-apsg076a7313/1.0/web/1.0#apd4768067dad604

</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="L3L-I8-sqk"/>
<menuItem title="Change Title..." id="24I-xg-qIq">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<menuItem title="Change Title..." id="24I-xg-qIq">
<menuItem title="Change Title" id="24I-xg-qIq">

menu.addItem(withTitle: "Reset Terminal", action: #selector(resetTerminal(_:)), keyEquivalent: "")
menu.addItem(withTitle: "Toggle Terminal Inspector", action: #selector(toggleTerminalInspector(_:)), keyEquivalent: "")
menu.addItem(.separator())
menu.addItem(withTitle: "Change Title...", action: #selector(changeTitle(_:)), keyEquivalent: "")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
menu.addItem(withTitle: "Change Title...", action: #selector(changeTitle(_:)), keyEquivalent: "")
menu.addItem(withTitle: "Change Title", action: #selector(changeTitle(_:)), keyEquivalent: "")

@mvolkmann
Copy link

This issue is marked as merged, but I have version 1.1.2 and when I right-click in a split in macOS I don't see the "Set Title" menu option. Is this change currently available for macOS?

@mitchellh
Copy link
Contributor

No it’s on tip. See the milestone this got attached to

@felipevolpone
Copy link

I'm on tip, but I'm not able to setup a keybind for this. I've tried:

keybind = cmd+i=change_title_prompt

but when I reload the config, I get the keybind: unknown error error.InvalidAction error.
Am I missing something?

@00-kat
Copy link
Contributor

00-kat commented Apr 16, 2025

It's not change_title_prompt anymore, you want prompt_surface_title.

syncMenuShortcut(config, action: "increase_font_size:1", menuItem: self.menuIncreaseFontSize)
syncMenuShortcut(config, action: "decrease_font_size:1", menuItem: self.menuDecreaseFontSize)
syncMenuShortcut(config, action: "reset_font_size", menuItem: self.menuResetFontSize)
syncMenuShortcut(config, action: "change_title_prompt", menuItem: self.menuChangeTitle)
Copy link
Contributor

@00-kat 00-kat Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is very suspicious though (it's still like this on the current main); every other instance is prompt_surface_title. (Corrected in #7149.)

@felipevolpone
Copy link

Thanks, that made it 🙌

One small feedback [1]: At least in mac os, when the popup appears the focus of the cursor is not on the text field, but on the "Cancel" button, which is kinda weird.

Not sure if it's possible to see with this screenshot:
Screenshot 2025-04-16 at 08 43 43

[1] If this is not the place for it, I'm happy to open an issue for it.

@00-kat
Copy link
Contributor

00-kat commented Apr 16, 2025

Yeah, open a new Discussion.

@felipevolpone
Copy link

For reference: #7105

mitchellh added a commit that referenced this pull request Apr 21, 2025
This was changed pretty late at
#4217 (comment),
and I don't think anybody saw my comment at
#4217 (comment);
I have no idea if this change is correct and have no way to test it
either as I don't use macOS, but I'm quite suspicious of that line
having not been changed.
@SachaG
Copy link

SachaG commented Jun 25, 2025

I'm running version 1.1.3 and not seeing a way to trigger the dialog. Has this been rolled back since? Is this feature documented anywhere?

@jcollie
Copy link
Member

jcollie commented Jun 25, 2025

I'm running version 1.1.3 and not seeing a way to trigger the dialog. Has this been rolled back since? Is this feature documented anywhere?

It is not part of 1.1.3 or any other released version. It will be part of 1.2 when it is released. Please read the comments more carefully before commenting on such an old closed PR.

@SachaG
Copy link

SachaG commented Jun 25, 2025

@jcollie sorry but it's not obvious which release this feature is attached to at first glance, so I think given that the PR was approved a couple months ago it's reasonable to assume the feature might already be part of the latest public release. Looking forward to 1.2 though :)

@jcollie
Copy link
Member

jcollie commented Jun 25, 2025

@jcollie sorry but it's not obvious which release this feature is attached to at first glance, so I think given that the PR was approved a couple months ago it's reasonable to assume the feature might already be part of the latest public release. Looking forward to 1.2 though :)

Check the "milestone" that this PR is attached to. It's up near the top on the right. It's even mentioned in a comment above.

@mitchellh
Copy link
Contributor

CleanShot 2025-06-24 at 22 04 20@2x

You can always tell where an issue or PR made it via this. This is managed by CI.

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 this pull request may close these issues.

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