Add -E to split-window to explicitly make an empty pane rather than

requiring an empty command.
This commit is contained in:
nicm
2026-06-07 13:15:28 +00:00
parent 5744021ac9
commit 306ee0eddb
2 changed files with 19 additions and 12 deletions

View File

@@ -39,7 +39,7 @@ const struct cmd_entry cmd_new_pane_entry = {
.name = "new-pane", .name = "new-pane",
.alias = "newp", .alias = "newp",
.args = { "bc:de:fF: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: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] "
@@ -57,7 +57,7 @@ const struct cmd_entry cmd_split_window_entry = {
.name = "split-window", .name = "split-window",
.alias = "splitw", .alias = "splitw",
.args = { "bc:de:fF:hIkl:m:p:PR:s:S:t:vZ", 0, -1, NULL }, .args = { "bc:de:EfF:hIkl:m:p:PR:s:S: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] "
@@ -84,7 +84,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct window_pane *wp = target->wp, *new_wp; struct window_pane *wp = target->wp, *new_wp;
struct layout_cell *lc = NULL; struct layout_cell *lc = NULL;
struct cmd_find_state fs; struct cmd_find_state fs;
int input, 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;
struct args_value *av; struct args_value *av;
@@ -94,14 +94,20 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
is_floating = !args_has(args, 'L'); is_floating = !args_has(args, 'L');
else else
is_floating = 0; is_floating = 0;
input = (args_has(args, 'I') && count == 0);
flags = is_floating ? SPAWN_FLOATING : 0; flags = is_floating ? SPAWN_FLOATING : 0;
if (args_has(args, 'b')) if (args_has(args, 'b'))
flags |= SPAWN_BEFORE; flags |= SPAWN_BEFORE;
if (args_has(args, 'f')) if (args_has(args, 'f'))
flags |= SPAWN_FULLSIZE; flags |= SPAWN_FULLSIZE;
if (input || (count == 1 && *args_string(args, 0) == '\0'))
input = args_has(args, 'I');
empty = (count == 1 && *args_string(args, 0) == '\0');
if (!empty && (input || args_has(args, 'E'))) {
cmdq_error(item, "command cannot be given for empty pane");
return (CMD_RETURN_ERROR);
}
if (input || empty || args_has(args, 'E'))
flags |= SPAWN_EMPTY; flags |= SPAWN_EMPTY;
if (is_floating) if (is_floating)

15
tmux.1
View File

@@ -3377,15 +3377,16 @@ but also sets the
option for this pane to option for this pane to
.Ar message . .Ar message .
.Pp .Pp
An empty .Fl E ,
.Ar shell\-command or an empty
(\[aq]\[aq]) will create a pane with no command running in it. .Ar shell\-command ,
(\[aq]\[aq]) will create an empty pane with no command running in it;
.Ic display-message
.Fl I
can write to an empty pane.
The The
.Fl I .Fl I
flag (if flag will create an empty pane and forward any output from stdin to it.
.Ar shell\-command
is not specified or empty)
will create an empty pane and forward any output from stdin to it.
For example: For example:
.Bd -literal -offset indent .Bd -literal -offset indent
$ make 2>&1|tmux splitw \-dI & $ make 2>&1|tmux splitw \-dI &