Add -T to new-pane to set the title; GitHub issue 5176 from Michael Grant.

This commit is contained in:
nicm
2026-06-08 20:44:57 +00:00
parent ea51cdb3f2
commit df7c2e605b
2 changed files with 33 additions and 9 deletions

View File

@@ -39,11 +39,11 @@ const struct cmd_entry cmd_new_pane_entry = {
.name = "new-pane", .name = "new-pane",
.alias = "newp", .alias = "newp",
.args = { "bc:de:EfF:hIkl:Lm:p:PR:s:S:t:vx:X:y:Y:Z", 0, -1, NULL }, .args = { "bc:de:EfF:hIkl:Lm:p:PR:s:S:t:T:vx:X:y:Y:Z", 0, -1, NULL },
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] " .usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
"[-F format] [-l size] [-m message] [-p percentage] " "[-F format] [-l size] [-m message] [-p percentage] "
"[-s style] [-S active-border-style] " "[-s style] [-S active-border-style] "
"[-R inactive-border-style] [-x width] [-y height] " "[-R inactive-border-style] [-T title] [-x width] [-y height] "
"[-X x-position] [-Y y-position] " CMD_TARGET_PANE_USAGE " " "[-X x-position] [-Y y-position] " CMD_TARGET_PANE_USAGE " "
"[shell-command [argument ...]]", "[shell-command [argument ...]]",
@@ -57,11 +57,11 @@ const struct cmd_entry cmd_split_window_entry = {
.name = "split-window", .name = "split-window",
.alias = "splitw", .alias = "splitw",
.args = { "bc:de:EfF:hIkl:m:p:PR:s:S:t:vZ", 0, -1, NULL }, .args = { "bc:de:EfF:hIkl:m:p:PR:s:S:t:T:vZ", 0, -1, NULL },
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] " .usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
"[-F format] [-l size] [-m message] [-p percentage] " "[-F format] [-l size] [-m message] [-p percentage] "
"[-s style] [-S active-border-style] " "[-s style] [-S active-border-style] "
"[-R inactive-border-style] " CMD_TARGET_PANE_USAGE " " "[-R inactive-border-style] [-T title] " CMD_TARGET_PANE_USAGE " "
"[shell-command [argument ...]]", "[shell-command [argument ...]]",
.target = { 't', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 },
@@ -86,7 +86,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state fs; struct cmd_find_state fs;
int input, empty, is_floating, flags = 0; int input, empty, is_floating, flags = 0;
const char *template, *style; const char *template, *style;
char *cause = NULL, *cp; char *cause = NULL, *cp, *title;
struct args_value *av; struct args_value *av;
u_int count = args_count(args); u_int count = args_count(args);
@@ -195,6 +195,12 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
"remain-on-exit-format", "remain-on-exit-format",
0, "%s", args_get(args, 'm')); 0, "%s", args_get(args, 'm'));
} }
if (args_has(args, 'T')) {
title = format_single_from_target(item, args_get(args, 'T'));
screen_set_title(&new_wp->base, title);
notify_pane("pane-title-changed", new_wp);
free(title);
}
if (input) { if (input) {
switch (window_pane_start_input(new_wp, item, &cause)) { switch (window_pane_start_input(new_wp, item, &cause)) {

26
tmux.1
View File

@@ -2741,7 +2741,7 @@ the end of the visible pane.
The default is to capture only the visible contents of the pane. The default is to capture only the visible contents of the pane.
.It Xo .It Xo
.Ic choose\-client .Ic choose\-client
.Op Fl NryZ .Op Fl kNryZ
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter .Op Fl f Ar filter
.Op Fl K Ar key\-format .Op Fl K Ar key\-format
@@ -2814,10 +2814,12 @@ specifies the format for each item in the list and
a format for each shortcut key; both are evaluated once for each line. a format for each shortcut key; both are evaluated once for each line.
.Fl N .Fl N
starts without the preview or if given twice with the larger preview. starts without the preview or if given twice with the larger preview.
.Fl k
kills the pane when the mode is exited.
This command works only if at least one client is attached. This command works only if at least one client is attached.
.It Xo .It Xo
.Ic choose\-tree .Ic choose\-tree
.Op Fl GNrswyZ .Op Fl GkNrswyZ
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter .Op Fl f Ar filter
.Op Fl K Ar key\-format .Op Fl K Ar key\-format
@@ -2907,10 +2909,12 @@ starts without the preview or if given twice with the larger preview.
.Fl G .Fl G
includes all sessions in any session groups in the tree rather than only the includes all sessions in any session groups in the tree rather than only the
first. first.
.Fl k
kills the pane when the mode is exited.
This command works only if at least one client is attached. This command works only if at least one client is attached.
.It Xo .It Xo
.Ic customize\-mode .Ic customize\-mode
.Op Fl NZ .Op Fl kNZ
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter .Op Fl f Ar filter
.Op Fl t Ar target\-pane .Op Fl t Ar target\-pane
@@ -2958,6 +2962,8 @@ If a filter would lead to an empty list, it is ignored.
specifies the format for each item in the tree. specifies the format for each item in the tree.
.Fl N .Fl N
starts without the option information. starts without the option information.
.Fl k
kills the pane when the mode is exited.
This command works only if at least one client is attached. This command works only if at least one client is attached.
.It Xo .It Xo
.Tg displayp .Tg displayp
@@ -3339,6 +3345,7 @@ but a different format may be specified with
.Op Fl s Ar style .Op Fl s Ar style
.Op Fl S Ar active\-border\-style .Op Fl S Ar active\-border\-style
.Op Fl t Ar target\-pane .Op Fl t Ar target\-pane
.Op Fl T Ar title
.Op Ar shell\-command Op Ar argument ... .Op Ar shell\-command Op Ar argument ...
.Xc .Xc
.D1 Pq alias: Ic newp .D1 Pq alias: Ic newp
@@ -3357,6 +3364,8 @@ sets the border style when the pane is active and
.Fl R .Fl R
sets the border style when the pane is inactive (see sets the border style when the pane is inactive (see
.Sx STYLES ) . .Sx STYLES ) .
.Fl T
sets the pane title.
.Pp .Pp
.Fl h .Fl h
does a horizontal split and does a horizontal split and
@@ -3754,6 +3763,7 @@ the command behaves like
.Op Fl s Ar style .Op Fl s Ar style
.Op Fl S Ar active\-border\-style .Op Fl S Ar active\-border\-style
.Op Fl t Ar target\-pane .Op Fl t Ar target\-pane
.Op Fl T Ar title
.Op Ar shell\-command Op Ar argument ... .Op Ar shell\-command Op Ar argument ...
.Xc .Xc
.D1 Pq alias: Ic splitw .D1 Pq alias: Ic splitw
@@ -4792,6 +4802,12 @@ command to show the indicator for the active pane.
Set the colour used by the Set the colour used by the
.Ic display\-panes .Ic display\-panes
command to show the indicators for inactive panes. command to show the indicators for inactive panes.
.It Ic display\-panes\-format Ar format
Set the
.Ar format
of the text shown by the
.Ic display\-panes
command, expanded for each pane.
.It Ic display\-panes\-time Ar time .It Ic display\-panes\-time Ar time
Set the time in milliseconds for which the indicators shown by the Set the time in milliseconds for which the indicators shown by the
.Ic display\-panes .Ic display\-panes
@@ -7615,7 +7631,7 @@ The buffer commands are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo .It Xo
.Ic choose\-buffer .Ic choose\-buffer
.Op Fl NryZ .Op Fl kNryZ
.Op Fl F Ar format .Op Fl F Ar format
.Op Fl f Ar filter .Op Fl f Ar filter
.Op Fl K Ar key\-format .Op Fl K Ar key\-format
@@ -7686,6 +7702,8 @@ specifies the format for each item in the list and
a format for each shortcut key; both are evaluated once for each line. a format for each shortcut key; both are evaluated once for each line.
.Fl N .Fl N
starts without the preview. starts without the preview.
.Fl k
kills the pane when the mode is exited.
This command works only if at least one client is attached. This command works only if at least one client is attached.
.Tg clearhist .Tg clearhist
.It Xo Ic clear\-history .It Xo Ic clear\-history