From 188f963fe081274a498dfcd992c2475b6df83a9f Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Dec 2025 08:35:04 +0000 Subject: [PATCH 1/3] Add {current}/{active} for -t for current window or active pane, from Manuel Einfalt in GitHub issue 4766. --- cmd-find.c | 15 +++++++++++++++ key-bindings.c | 2 ++ tmux.1 | 2 ++ 3 files changed, 19 insertions(+) diff --git a/cmd-find.c b/cmd-find.c index c651448d..761f133f 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -925,6 +925,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, const char *target, enum cmd_find_type type, int flags) { struct mouse_event *m; + struct client *c; struct cmd_find_state current; char *colon, *period, *copy = NULL, tmp[256]; const char *session, *window, *pane, *s; @@ -991,6 +992,20 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, if (target == NULL || *target == '\0') goto current; + if (strcmp(target, "@") == 0 || + strcmp(target, "{active}") == 0 || + strcmp(target, "{current}") == 0) { + c = cmdq_get_client(item); + if (c == NULL) { + cmdq_error(item, "no current client"); + goto error; + } + fs->wl = c->session->curw; + fs->wp = c->session->curw->window->active; + fs->w = c->session->curw->window; + goto found; + } + /* Mouse target is a plain = or {mouse}. */ if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { m = &cmdq_get_event(item)->m; diff --git a/key-bindings.c b/key-bindings.c index 22e5cf59..2dd2b742 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -439,6 +439,7 @@ key_bindings_init(void) /* Mouse button 1 down on pane. */ "bind -n MouseDown1Pane { select-pane -t=; send -M }", + "bind -n C-MouseDown1Pane { swap-pane -s@ }", /* Mouse button 1 drag on pane. */ "bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }", @@ -460,6 +461,7 @@ key_bindings_init(void) /* Mouse button 1 down on status line. */ "bind -n MouseDown1Status { switch-client -t= }", + "bind -n C-MouseDown1Status { swap-window -t@ }", /* Mouse wheel down on status line. */ "bind -n WheelDownStatus { next-window }", diff --git a/tmux.1 b/tmux.1 index 6e5b70f7..2af98b8f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -839,6 +839,7 @@ Each has a single-character alternative form. .It Li "{last}" Ta "!" Ta "The last (previously current) window" .It Li "{next}" Ta "+" Ta "The next window by number" .It Li "{previous}" Ta "-" Ta "The previous window by number" +.It Li "{current}" Ta "@" Ta "The current window" .El .Pp .Ar target-pane @@ -871,6 +872,7 @@ The following special tokens are available for the pane index: .It Li "{down-of}" Ta "" Ta "The pane below the active pane" .It Li "{left-of}" Ta "" Ta "The pane to the left of the active pane" .It Li "{right-of}" Ta "" Ta "The pane to the right of the active pane" +.It Li "{active}" Ta "@" Ta "The active pane" .El .Pp The tokens From a22ec275b4ea01992114fa560671046c6aa88a9c Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Dec 2025 08:39:35 +0000 Subject: [PATCH 2/3] With status-keys vi, move the cursor left by one when pressing Escape to enter command mode, like vi. GitHub issue 4767 from Joshua Cooper. --- status.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/status.c b/status.c index 0551b547..3cda11fb 100644 --- a/status.c +++ b/status.c @@ -936,6 +936,8 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key) return (1); case '\033': /* Escape */ c->prompt_mode = PROMPT_COMMAND; + if (c->prompt_index != 0) + c->prompt_index--; c->flags |= CLIENT_REDRAWSTATUS; return (0); } @@ -961,10 +963,11 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key) *new_key = 'u'|KEYC_CTRL; return (1); case 'i': - case '\033': /* Escape */ c->prompt_mode = PROMPT_ENTRY; c->flags |= CLIENT_REDRAWSTATUS; return (0); + case '\033': /* Escape */ + return (0); } switch (key) { From d005803934c1bb5e6ad9658b19d5704971e0401b Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Dec 2025 08:41:01 +0000 Subject: [PATCH 3/3] Add prompt-command-cursor-style, from Joshua Cooper in GitHub issue 4765. --- options-table.c | 9 +++++++++ status.c | 5 ++++- tmux.1 | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/options-table.c b/options-table.c index 4385c9fd..f056966d 100644 --- a/options-table.c +++ b/options-table.c @@ -971,6 +971,15 @@ const struct options_table_entry options_table[] = { .text = "Style of the cursor when in the command prompt." }, + { .name = "prompt-command-cursor-style", + .type = OPTIONS_TABLE_CHOICE, + .scope = OPTIONS_TABLE_SESSION, + .choices = options_table_cursor_style_list, + .default_num = 0, + .text = "Style of the cursor in the command prompt when in command " + "mode, if 'status-keys' is set to 'vi'." + }, + { .name = "session-status-current-style", .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_WINDOW, diff --git a/status.c b/status.c index 3cda11fb..79ce9cad 100644 --- a/status.c +++ b/status.c @@ -804,7 +804,10 @@ status_prompt_redraw(struct client *c) n = options_get_number(s->options, "prompt-cursor-colour"); sl->active->default_ccolour = n; - n = options_get_number(s->options, "prompt-cursor-style"); + if (c->prompt_mode == PROMPT_COMMAND) + n = options_get_number(s->options, "prompt-command-cursor-style"); + else + n = options_get_number(s->options, "prompt-cursor-style"); screen_set_cursor_style(n, &sl->active->default_cstyle, &sl->active->default_mode); diff --git a/tmux.1 b/tmux.1 index 2af98b8f..fe228dd2 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4696,6 +4696,12 @@ Set the style of the cursor in the command prompt. See the .Ic cursor-style options for available styles. +.It Ic prompt-command-cursor-style Ar style +Set the style of the cursor in the command prompt when vi keys are enabled and +the prompt is in command mode. +See the +.Ic cursor-style +options for available styles. .It Xo Ic renumber-windows .Op Ic on | off .Xc