From 188f963fe081274a498dfcd992c2475b6df83a9f Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 22 Dec 2025 08:35:04 +0000 Subject: [PATCH] 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