Skip to content

Commit

Permalink
Add alt keybindings for ctrl+ins = Copy and shift+ins = Paste (#2870)
Browse files Browse the repository at this point in the history
On non-MacOS desktop environments (Windows, Gnome, KDE, Xfce, VS Code,
...), `ctrl+ins` and `shift+ins` are system-wide alternate keybindings
(except for terminals) for `Copy` and `Paste` respectively. This PR
explicitly defines them as such in Ghostty's default keybindings.

Using `ctrl+ins` as an alt-keybinding for `Copy` allows
static/context-unaware remapping of `Copy` to `cmd+c` for Linux systems
using Mac keyboards via
[keyd](NixOS/nixpkgs#137698 (comment));
with the default `ctrl+shift+c` keybinding for copy this is basically
impossible (because that binding only applies to terminals).
  • Loading branch information
mitchellh authored Jan 2, 2025
2 parents 9503c9f + a469191 commit 80c3833
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/config/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,20 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
.{ .key = .{ .translated = .v }, .mods = mods },
.{ .paste_from_clipboard = {} },
);
// On non-MacOS desktop envs (Windows, KDE, Gnome, Xfce), ctrl+insert is an
// alt keybinding for Copy and shift+ins is an alt keybinding for Paste
if (!builtin.target.isDarwin()) {
try result.keybind.set.put(
alloc,
.{ .key = .{ .translated = .insert }, .mods = .{ .ctrl = true } },
.{ .copy_to_clipboard = {} },
);
try result.keybind.set.put(
alloc,
.{ .key = .{ .translated = .insert }, .mods = .{ .shift = true } },
.{ .paste_from_clipboard = {} },
);
}
}

// Increase font size mapping for keyboards with dedicated plus keys (like german)
Expand Down

0 comments on commit 80c3833

Please sign in to comment.