Add -g flag to kill-session to kill all sessions in a group, GitHub

issue 5157 from github at jiku dot jp.
This commit is contained in:
nicm
2026-06-07 13:51:42 +00:00
parent 0256ee77c2
commit 343ee5ece1
2 changed files with 14 additions and 3 deletions

View File

@@ -33,8 +33,8 @@ const struct cmd_entry cmd_kill_session_entry = {
.name = "kill-session",
.alias = NULL,
.args = { "aCt:", 0, 0, NULL },
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
.args = { "aCgt:", 0, 0, NULL },
.usage = "[-aCg] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 },
@@ -48,6 +48,7 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s, *sloop, *stmp;
struct session_group *sg;
struct winlink *wl;
if (args_has(args, 'C')) {
@@ -63,6 +64,12 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
session_destroy(sloop, 1, __func__);
}
}
} else if (args_has(args, 'g') &&
(sg = session_group_contains(s)) != NULL) {
TAILQ_FOREACH_SAFE(sloop, &sg->sessions, gentry, stmp) {
server_destroy_session(sloop);
session_destroy(sloop, 1, __func__);
}
} else {
server_destroy_session(s);
session_destroy(s, 1, __func__);

6
tmux.1
View File

@@ -1202,7 +1202,7 @@ Kill the
.Nm
server and clients and destroy all sessions.
.It Xo Ic kill\-session
.Op Fl aC
.Op Fl aCg
.Op Fl t Ar target\-session
.Xc
Destroy the given session, closing any windows linked to it and no other
@@ -1210,6 +1210,10 @@ sessions, and detaching all clients attached to it.
If
.Fl a
is given, all sessions but the specified one is killed.
If
.Fl g
is given and the session is in a session group, all sessions in the group are
killed.
The
.Fl C
flag clears alerts (bell, activity, or silence) in all windows linked to the