keybind: add copy_title action

Fixes #7829

This will copy the terminal title to the clipboard. If the terminal
title is not set it has no effect.
This commit is contained in:
Jeffrey C. Ollie
2025-07-06 12:12:27 -05:00
parent d790b0f60e
commit 3cf56b8af3
3 changed files with 22 additions and 0 deletions

View File

@ -4443,6 +4443,17 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
return false;
},
.copy_title => {
const title = self.rt_surface.getTitle() orelse return false;
self.rt_surface.setClipboardString(title, .standard, false) catch |err| {
log.err("error copying title to clipboard err={}", .{err});
return true;
};
return true;
},
.paste_from_clipboard => try self.startClipboardRequest(
.standard,
.{ .paste = {} },

View File

@ -281,6 +281,10 @@ pub const Action = union(enum) {
/// If there is a URL under the cursor, copy it to the default clipboard.
copy_url_to_clipboard,
/// Copy the terminal title to the clipboard. If the terminal title is not
/// set this has no effect.
copy_title,
/// Increase the font size by the specified amount in points (pt).
///
/// For example, `increase_font_size:1.5` will increase the font size
@ -1005,6 +1009,7 @@ pub const Action = union(enum) {
.reset,
.copy_to_clipboard,
.copy_url_to_clipboard,
.copy_title,
.paste_from_clipboard,
.paste_from_selection,
.increase_font_size,

View File

@ -132,6 +132,12 @@ fn actionCommands(action: Action.Key) []const Command {
.description = "Copy the URL under the cursor to the clipboard.",
}},
.copy_title => comptime &.{.{
.action = .copy_title,
.title = "Copy Terminal Title to Clipboard",
.description = "Copy the terminal title to the clipboard. If the terminal title is not set this has no effect.",
}},
.paste_from_clipboard => comptime &.{.{
.action = .paste_from_clipboard,
.title = "Paste from Clipboard",