summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-list-sessions.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-10 10:02:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-10 10:02:49 +0000
commit1a7d94b31f73fd2780347ed40c36a275984d82f5 (patch)
treec75a5b36b46e37774308415dee9f0d21d80cf252 /usr.bin/tmux/cmd-list-sessions.c
parent930bee8dee77f0a986fac1edcc836ff0d62c5165 (diff)
Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing windows and so on are mirrored between the sessions). A grouped session may be created by passing -t to new-session. Had this around for a while, tested by a couple of people.
Diffstat (limited to 'usr.bin/tmux/cmd-list-sessions.c')
-rw-r--r--usr.bin/tmux/cmd-list-sessions.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-list-sessions.c b/usr.bin/tmux/cmd-list-sessions.c
index 9c03f5589ac..74ecc6e2682 100644
--- a/usr.bin/tmux/cmd-list-sessions.c
+++ b/usr.bin/tmux/cmd-list-sessions.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-sessions.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-list-sessions.c,v 1.4 2009/10/10 10:02:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,23 +42,32 @@ const struct cmd_entry cmd_list_sessions_entry = {
int
cmd_list_sessions_exec(unused struct cmd *self, struct cmd_ctx *ctx)
{
- struct session *s;
- char *tim;
- u_int i;
- time_t t;
+ struct session *s;
+ struct session_group *sg;
+ char *tim, tmp[64];
+ u_int i, idx;
+ time_t t;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL)
continue;
+ sg = session_group_find(s);
+ if (sg == NULL)
+ *tmp = '\0';
+ else {
+ idx = session_group_index(sg);
+ xsnprintf(tmp, sizeof tmp, " (group %u)", idx);
+ }
+
t = s->tv.tv_sec;
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
- ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s",
+ ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]%s%s",
s->name, winlink_count(&s->windows), tim, s->sx, s->sy,
- s->flags & SESSION_UNATTACHED ? "" : " (attached)");
+ tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
}
return (0);