From d33309543793148241263ea162cc5e838ebd0c98 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 16 Feb 2026 14:11:00 +0530 Subject: [PATCH] Cleanup previous PR --- docs/changelog.rst | 2 ++ kitty/window.py | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 56a850321..6517f419e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -225,6 +225,8 @@ Detailed list of changes - Shell integration: Allow sending click events to shells using y co-ordinates relative to prompts (:iss:`9500`) +- A new action :ac:`copy_selection_or_last_command_output` (:pull:`9512`) + 0.45.0 [2025-12-24] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/window.py b/kitty/window.py index c7f31c4a0..17527a312 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -2234,15 +2234,11 @@ class Window: self.copy_or_interrupt() self.screen.clear_selection() - @ac('cp', 'Copy the selected text from the active window to the clipboard, if no selection, copy the last command output') - def copy_last_command_output_or_clipboard(self) -> None: - text = self.text_for_selection() - if text: + @ac('cp', 'Copy the selected text from the active window to the clipboard,' + ' if no selection, copy the last command output (requires shell integration to work)') + def copy_selection_or_last_command_output(self) -> None: + if (text := self.text_for_selection() or self.cmd_output(CommandOutput.last_non_empty, as_ansi=False, add_wrap_markers=False)): set_clipboard_string(text) - else: - text = self.cmd_output(CommandOutput.last_non_empty, as_ansi=False, add_wrap_markers=False) - if text: - set_clipboard_string(text) @ac('cp', 'Pass the selected text from the active window to the specified program') def pass_selection_to_program(self, *args: str) -> None: