Skip to content

Instantly share code, notes, and snippets.

@robbyrob42
Forked from trashhalo/ghostty-shortcuts.md
Last active December 30, 2024 22:35
Show Gist options
  • Save robbyrob42/c139fb451e0055c63acbce4db9372db3 to your computer and use it in GitHub Desktop.
Save robbyrob42/c139fb451e0055c63acbce4db9372db3 to your computer and use it in GitHub Desktop.

Ghostty Key Operations

Fonts

ghostty +list-fonts

Themes

ghostty +list-themes

Config

ghostty +show-config

Key Binds

ghostty +list-actions

Custom Keybinds

EDIT: DON'T WRITE YOUR OWN KEYBINDS, use Ghostty Config by zerebos and export the UI driven config into XDG_CONFIG_HOME/ghostty/config and enjoy yourself!


title: Custom Keybindings description: Associate a keypress with a specific action.

Ghostty supports flexible, custom keybindings through the keybind configuration option. The configuration reference has detailed reference documentation for the option, but this page will give a high-level overview of how to specify keybindings in Ghostty.

The basic syntax of a keybinding configuration is:

keybind = trigger=action

Trigger

The trigger part of a keybinding specifies the keypress events that will trigger the action. The trigger can be a single key, a single key with modifiers, or a sequence of keys.

A trigger has zero or more modifiers combined with one key. For example, a, ctrl+a, ctrl+shift+a, ctrl+alt+a are all valid triggers.

The set of possible keys is currently only available for reference by viewing the source code. This list is derived from Chromium's keycodes and is closely associated with keys that have associated USB HID codes.

If a key is not in the list, you can also specify a Unicode codepoint. If your key can decode into a single Unicode codepoint, Ghostty will consider it a valid trigger and the trigger will activate when a keypress event occurs which generates that codepoint. This is particularly useful on non-US keyboard layouts.

For example, on a German keyboard you could bind "ö" with the configuration below. This would trigger when the "ö" key is pressed (";" on a US physical keyboard) because that key generates "ö" in Unicode.

keybind = ctrl+ö=action

Modifiers

Valid modifiers are:

  • shift
  • ctrl (alias: control)
  • alt (alias: opt, option)
  • super (alias: cmd, command)
The fn or "globe" key on keyboards are not supported as a modifier. This is a limitation of the operating systems and GUI toolkits that Ghostty uses.

Trigger Prefixes

A trigger can also be prefixed with some special values to change the behavior of the keybind. These are listed below.

Keybind triggers are not unique per prefix combination. For example, ctrl+a and global:ctrl+a are not two separate keybinds. The keybind set later will overwrite the keybind set earlier. In this case, the global: keybind will be used.

Multiple prefixes can be specified. For example, global:unconsumed:ctrl+a=reload_config will make the keybind global in addition to not consuming the input to reload the config.

all:

Make the keybind apply to all terminal surfaces. By default, keybinds only apply to the focused terminal surface. If this is true, then the keybind will be sent to all terminal surfaces. This only applies to actions that are surface-specific. For actions that are already global (i.e. quit), this prefix has no effect.

global:

Make the keybind global. By default, keybinds only work within Ghostty and under the right conditions (application focused, sometimes terminal focused, etc.). If you want a keybind to work globally across your system (i.e. even when Ghostty is not focused), specify this prefix. This prefix implies all:. Note: this does not work in all environments; see the additional notes below for more information.

This feature is only supported on macOS. On macOS, this feature requires accessibility permissions to be granted to Ghostty. When a global: keybind is specified and Ghostty is launched or reloaded, Ghostty will attempt to request these permissions. If the permissions are not granted, the keybind will not work. On macOS, you can find these permissions in System Preferences -> Privacy & Security -> Accessibility.

The `global:` prefix is only available on macOS.

unconsumed:

Do not consume the input. By default, a keybind will consume the input, meaning that the associated encoding (if any) will not be sent to the running program in the terminal. If you wish to send the encoded value to the program, specify the unconsumed: prefix before the entire keybind. For example: unconsumed:ctrl+a=reload_config.

global: and all:-prefixed keybinds will always consume the input regardless of this setting. Since they are not associated with a specific terminal surface, they're never encoded.

Action

Action is what happens when the trigger is activated. It is in the format of action or action:parameter if the action requires a parameter.

Here are some common actions that can be used in keybinds. Please view the full list of actions for a complete list. Ghostty supports dozens of actions.

Action Description
ignore Do nothing, ignore the key input. This can be used to black hole certain inputs to have no effect and no encoding.
unbind Remove the binding. This makes it so the previous action is removed, and the key will be sent through to the child command if it is printable.
text:text Send a string. Uses Zig string literal syntax. i.e. text:\x15 sends Ctrl-U. By using a prefix of \x1b[ you can send control sequences but the convenience actions csi: and esc: are recommended instead.
csi:text Send a CSI sequence. i.e. csi:A sends "cursor up".
esc:text Send an escape sequence. i.e. esc:d deletes to the end of the word to the right.

Ghostty Keyboard Shortcuts

Default keyboard shortcuts for Ghostty terminal emulator. Platform-specific differences are noted where applicable.

Window Management

Action Windows/Linux macOS
New window Ctrl+Shift+N Cmd+N
Close window Alt+F4 Cmd+Shift+W
Close all windows - Cmd+Shift+Option+W
Toggle fullscreen Ctrl+Enter Cmd+Enter or Cmd+Ctrl+F
Quit application Ctrl+Shift+Q Cmd+Q

Tab Management

Action Windows/Linux macOS
New tab Ctrl+Shift+T Cmd+T
Close tab/surface Ctrl+Shift+W Cmd+W
Previous tab Ctrl+Shift+Tab, Ctrl+Shift+Left, Ctrl+Page Up Cmd+Shift+[
Next tab Ctrl+Tab, Ctrl+Shift+Right, Ctrl+Page Down Cmd+Shift+]
Go to tab 1-8 Alt+[1-8] Cmd+[1-8]
Go to last tab Alt+9 Cmd+9
Move tab - -

Split Management

Action Windows/Linux macOS
New split (right) Ctrl+Shift+O Cmd+D
New split (down) Ctrl+Shift+E Cmd+Shift+D
Focus previous split Ctrl+Super+[ Cmd+[
Focus next split Ctrl+Super+] Cmd+]
Focus split up Ctrl+Alt+Up Cmd+Option+Up
Focus split down Ctrl+Alt+Down Cmd+Option+Down
Focus split left Ctrl+Alt+Left Cmd+Option+Left
Focus split right Ctrl+Alt+Right Cmd+Option+Right
Toggle split zoom Ctrl+Shift+Enter Cmd+Shift+Enter
Resize split up Ctrl+Super+Shift+Up Cmd+Ctrl+Up
Resize split down Ctrl+Super+Shift+Down Cmd+Ctrl+Down
Resize split left Ctrl+Super+Shift+Left Cmd+Ctrl+Left
Resize split right Ctrl+Super+Shift+Right Cmd+Ctrl+Right
Equalize splits Ctrl+Super+Shift+= Cmd+Ctrl+=

Copy & Paste

Action Windows/Linux macOS
Copy Ctrl+Shift+C Cmd+C
Paste Ctrl+Shift+V Cmd+V
Paste from selection Shift+Insert -

Text Navigation

Action Windows/Linux macOS
Scroll to top Shift+Home Cmd+Home
Scroll to bottom Shift+End Cmd+End
Scroll page up Shift+Page Up Cmd+Page Up
Scroll page down Shift+Page Down Cmd+Page Down
Jump to previous prompt Ctrl+Shift+Page Up Cmd+Up
Jump to next prompt Ctrl+Shift+Page Down Cmd+Down
Clear screen - Cmd+K

Font Size

Action Windows/Linux macOS
Increase font size Ctrl++/Ctrl+= Cmd++/Cmd+=
Decrease font size Ctrl+- Cmd+-
Reset font size Ctrl+0 Cmd+0

Configuration

Action Windows/Linux macOS
Open config Ctrl+, Cmd+,
Reload config Ctrl+Shift+, Cmd+Shift+,

Inspector

Action Windows/Linux macOS
Toggle inspector Ctrl+Shift+I Cmd+Option+I

Scrollback

Action Windows/Linux macOS
Write scrollback to file (paste) Ctrl+Shift+J Cmd+Shift+J
Write scrollback to file (open) Ctrl+Shift+Alt+J Cmd+Shift+Option+J

Note: These are the default keybindings. All keybindings can be customized through the configuration file using the keybind option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment