diff --git a/format.c b/format.c index 10ac613e..497b5b52 100644 --- a/format.c +++ b/format.c @@ -401,10 +401,8 @@ format_session(struct format_tree *ft, struct session *s) *strchr(tim, '\n') = '\0'; format_add(ft, "session_created_string", "%s", tim); - if (s->flags & SESSION_UNATTACHED) - format_add(ft, "session_attached", "%d", 0); - else - format_add(ft, "session_attached", "%d", 1); + format_add(ft, "session_attached", "%u", s->attached); + format_add(ft, "session_many_attached", "%u", s->attached > 1); } /* Set default format keys for a client. */ diff --git a/resize.c b/resize.c index 8d0bd275..b3b031c0 100644 --- a/resize.c +++ b/resize.c @@ -55,6 +55,7 @@ recalculate_sizes(void) RB_FOREACH(s, sessions, &sessions) { has_status = options_get_number(&s->options, "status"); + s->attached = 0; ssx = ssy = UINT_MAX; for (j = 0; j < ARRAY_LENGTH(&clients); j++) { c = ARRAY_ITEM(&clients, j); @@ -69,6 +70,7 @@ recalculate_sizes(void) ssy = c->tty.sy - 1; else if (c->tty.sy < ssy) ssy = c->tty.sy; + s->attached++; } } if (ssx == UINT_MAX || ssy == UINT_MAX) { diff --git a/tmux.1 b/tmux.1 index 51d927a5..c9e5815a 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3141,13 +3141,14 @@ The following variables are available, where appropriate: .It Li "saved_cursor_y" Ta "" Ta "Saved cursor Y in pane" .It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane" .It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane" -.It Li "session_attached" Ta "" Ta "1 if session attached" +.It Li "session_attached" Ta "" Ta "Number of clients session is attached to" .It Li "session_created" Ta "" Ta "Integer time session created" .It Li "session_created_string" Ta "" Ta "String time session created" .It Li "session_group" Ta "" Ta "Number of session group" .It Li "session_grouped" Ta "" Ta "1 if session in a group" .It Li "session_height" Ta "" Ta "Height of session" .It Li "session_id" Ta "" Ta "Unique session ID" +.It Li "session_many_attached" Ta "" Ta "1 if multiple clients attached" .It Li "session_name" Ta "#S" Ta "Name of session" .It Li "session_width" Ta "" Ta "Width of session" .It Li "session_windows" Ta "" Ta "Number of windows in session" diff --git a/tmux.h b/tmux.h index 0a6ca4e4..fb2fb940 100644 --- a/tmux.h +++ b/tmux.h @@ -1083,6 +1083,8 @@ struct session { #define SESSION_UNATTACHED 0x1 /* not attached to any clients */ int flags; + u_int attached; + struct termios *tio; struct environ environ;