From 96f4c7b9faf02b14bf49260e8fb3848f8b7ffb72 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 8 Sep 2026 07:31:59 +0000 Subject: [PATCH] Add capture-pane -I to show times. --- cmd-capture-pane.c | 20 +++++++++++++------- tmux.1 | 8 +++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index baf6fc62d..5b7c922ba 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-capture-pane.c,v 1.68 2026/07/20 11:16:33 nicm Exp $ */ +/* $OpenBSD: cmd-capture-pane.c,v 1.69 2026/09/08 07:31:59 nicm Exp $ */ /* * Copyright (c) 2009 Jonathan Alvarado @@ -43,8 +43,8 @@ const struct cmd_entry cmd_capture_pane_entry = { .name = "capture-pane", .alias = "capturep", - .args = { "ab:CeE:FHJLMNpPqRS:Tt:", 0, 0, NULL }, - .usage = "[-aCeFHJLMNpPqRT] " CMD_BUFFER_USAGE " [-E end-line] " + .args = { "ab:CeE:FHIJLMNpPqRS:Tt:", 0, 0, NULL }, + .usage = "[-aCeFHIJLMNpPqRT] " CMD_BUFFER_USAGE " [-E end-line] " "[-S start-line] " CMD_TARGET_PANE_USAGE, .target = { 't', CMD_FIND_PANE, 0 }, @@ -201,7 +201,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp, tmp[0] = line[i]; tmp[1] = '\0'; } else - xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]); + snprintf(tmp, sizeof tmp, "\\%03hho", line[i]); buf = cmd_capture_pane_append(buf, len, tmp, strlen(tmp)); } @@ -260,7 +260,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item, struct grid_cell *gc = NULL; struct window_mode_entry *wme; int n, join_lines, number_lines, flags = 0; - int show_flags, hyperlinks; + int show_flags, show_time, hyperlinks; u_int *links = NULL, nlinks = 0; u_int i, sx, top, bottom, tmp; char *cause, *buf = NULL, *line, b[64], *cp; @@ -343,6 +343,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item, flags |= GRID_STRING_TRIM_SPACES; number_lines = args_has(args, 'L'); show_flags = args_has(args, 'F'); + show_time = args_has(args, 'I'); hyperlinks = args_has(args, 'H'); if (hyperlinks) links = xreallocarray(NULL, gd->sx, sizeof *links); @@ -359,6 +360,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item, free(line); continue; } + gl = grid_peek_line(gd, i); if (number_lines) { if (i >= gd->hsize) @@ -369,11 +371,16 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item, if (n >= 0) buf = cmd_capture_pane_append(buf, len, b, n); } + if (show_time) { + n = snprintf(b, sizeof b, "%llu ", + (unsigned long long)grid_line_time(gl)); + if (n >= 0) + buf = cmd_capture_pane_append(buf, len, b, n); + } if (show_flags) { cp = b; *cp = '\0'; - gl = grid_peek_line(gd, i); if (gl->flags & GRID_LINE_DEAD) *cp++ = 'D'; if (gl->flags & GRID_LINE_HYPERLINK) @@ -394,7 +401,6 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item, } buf = cmd_capture_pane_append(buf, len, line, linelen); - gl = grid_peek_line(gd, i); if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED)) buf[(*len)++] = '\n'; diff --git a/tmux.1 b/tmux.1 index f73d3f5b9..81d9fc287 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.1164 2026/09/03 21:04:11 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.1165 2026/09/08 07:31:59 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 3 2026 $ +.Dd $Mdocdate: September 8 2026 $ .Dt TMUX 1 .Os .Sh NAME @@ -2786,7 +2786,7 @@ The pane must not already be floating or hidden, and the window must not be zoomed. .Tg capturep .It Xo Ic capture\-pane -.Op Fl aeFHLpPRqCJMN +.Op Fl aeFHILpPRqCJMN .Op Fl b Ar buffer\-name .Op Fl E Ar end\-line .Op Fl S Ar start\-line @@ -2828,6 +2828,8 @@ captures only any output that the pane has received that is the beginning of an as-yet incomplete escape sequence. .Fl L includes the line number at the start of each line and +.Fl I +includes the time each line entered the history, or zero if not available. .Fl F includes the flags (where .Ql -