diff --git a/regress/output-commands.sh b/regress/output-commands.sh index 52eef4d29..caf2d5b80 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 2a0f86f85..ae53cccb8 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2338,6 +2338,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 2561d99ef..0a4e4e984 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4867,6 +4867,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,