From a8b05dd7d7420f6487c52e493629aaae91c4b2be Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Mon, 14 Sep 2026 06:25:40 +0100 Subject: [PATCH] Add pipe-selection copy mode command --- regress/output-commands.sh | 7 +++++++ tmux.1 | 7 +++++++ window-copy.c | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/regress/output-commands.sh b/regress/output-commands.sh index 5b67efb6a..87833427f 100755 --- a/regress/output-commands.sh +++ b/regress/output-commands.sh @@ -37,6 +37,13 @@ $TMUX send-keys -X copy-selection || exit 1 [ "$($TMUX show-buffer)" = unfinished ] || exit 1 $TMUX send-keys -X cancel || exit 1 +$TMUX copy-mode || exit 1 +$TMUX send-keys -X select-output || exit 1 +$TMUX send-keys -X pipe-selection "wc -c >$OUT" || exit 1 +sleep 1 +[ "$(cat "$OUT")" = 10 ] || exit 1 +$TMUX send-keys -X cancel || exit 1 + $TMUX copy-mode || exit 1 $TMUX send-keys -X search-backward separator || exit 1 $TMUX send-keys -X copy-output || exit 1 diff --git a/tmux.1 b/tmux.1 index 8e10a34e6..a60b169b7 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2317,6 +2317,13 @@ Pipe the current OSC 133 command output to .Ar command and clear the selection. .It Xo +.Ic pipe\-selection +.Op Ar command +.Xc +Pipe the selected text to +.Ar command +and clear the selection. +.It Xo .Ic previous\-matching\-bracket (emacs: M\-C\-b) .Xc diff --git a/window-copy.c b/window-copy.c index 15d288be6..e4b58a185 100644 --- a/window-copy.c +++ b/window-copy.c @@ -3904,6 +3904,12 @@ static const struct { .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, .f = window_copy_cmd_pipe_output }, + { .command = "pipe-selection", + .args = { "", 0, 1, NULL }, + .flags = 0, + .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, + .f = window_copy_cmd_pipe + }, { .command = "previous-matching-bracket", .args = { "", 0, 0, NULL }, .flags = WINDOW_COPY_CMD_FLAG_READONLY,