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

Keybind features: System-global keybindings and target-all-terminal keybindings #2299

Merged
merged 13 commits into from
Sep 25, 2024

Conversation

mitchellh
Copy link
Contributor

This PR introduces two distinct but related features:

  • System-global keybindings. These are notated with the prefix global:. These keybindings will work globally on the system, regardless of what application is focused. This currently only works for macOS and requires accessibility privileges. More on this UX later.

  • Target-all-terminal keybindings. These are notated with the prefix all:. These keybindings target all running terminal surfaces (windows, tabs, splits) in the Ghostty process. This can be used for example to implement increase_font_size across the entire application: keybind = all:cmd+plus=increase_font_size:1. This works on macOS and Linux.

The documentation on the various edge cases and details about these new features is immense. Please see src/config/Config.zig since I think this will answer most questions. If there are any improvements to docs I can make please suggest them.

macOS Accessibility Privilege

The global: keybind feature requires the accessibility privilege on macOS. Ghostty will automatically request this whenever the configuration contains any global: key binds. If there are no global: bindings presenting the configuration, Ghostty will not request or use the accessibility privilege.

Note that if a user has already denied it, macOS will not pop up the request prompt again. There is currently no UX to detect this but that's something I'd love to see improved in the future. Detection is trivial, but the UX around the detection requires much more thought.

You can see a demo of this in the video below.

Demo: System-Global Keybinds

We use keybind = global:cmd+period=new_window to create a keybind that creates and focuses a new Ghostty window regardless of what application is in focus. This can mimic a "quick terminal" type feature:

CleanShot.2024-09-24.at.18.45.11.mp4

Demo: Target-all-terminal Binding

We use keybind = all:cmd+j=text:hello to write text in all terminals.

CleanShot.2024-09-24.at.18.47.04.mp4

@mitchellh mitchellh merged commit d6e9db4 into main Sep 25, 2024
34 checks passed
@mitchellh mitchellh deleted the global-keybind branch September 25, 2024 04:01
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.

1 participant