From 16f33bed37ad95e879183314dacedc859900a6a4 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 19 May 2023 07:46:34 +0000 Subject: [PATCH] Add format for server_sessions, from Magnus Gross. --- usr.bin/tmux/format.c | 17 ++++++++++++++++- usr.bin/tmux/tmux.1 | 5 +++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 223441aaece..7420ec114cf 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.312 2023/03/27 08:47:57 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.313 2023/05/19 07:46:34 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -2077,6 +2077,18 @@ format_cb_scroll_region_upper(struct format_tree *ft) return (NULL); } +/* Callback for server_sessions. */ +static void * +format_cb_server_sessions(__unused struct format_tree *ft) +{ + struct session *s; + u_int n = 0; + + RB_FOREACH(s, sessions, &sessions) + n++; + return (format_printf("%u", n)); +} + /* Callback for session_attached. */ static void * format_cb_session_attached(struct format_tree *ft) @@ -2980,6 +2992,9 @@ static const struct format_table_entry format_table[] = { { "scroll_region_upper", FORMAT_TABLE_STRING, format_cb_scroll_region_upper }, + { "server_sessions", FORMAT_TABLE_STRING, + format_cb_server_sessions + }, { "session_activity", FORMAT_TABLE_TIME, format_cb_session_activity }, diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 40bb173ee32..4c8500327b0 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.919 2023/04/28 06:12:27 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.920 2023/05/19 07:46:34 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 28 2023 $ +.Dd $Mdocdate: May 19 2023 $ .Dt TMUX 1 .Os .Sh NAME @@ -5275,6 +5275,7 @@ The following variables are available, where appropriate: .It Li "selection_present" Ta "" Ta "1 if selection started in copy mode" .It Li "selection_start_x" Ta "" Ta "X position of the start of the selection" .It Li "selection_start_y" Ta "" Ta "Y position of the start of the selection" +.It Li "server_sessions" Ta "" Ta "Number of sessions" .It Li "session_activity" Ta "" Ta "Time of session last activity" .It Li "session_alerts" Ta "" Ta "List of window indexes with alerts" .It Li "session_attached" Ta "" Ta "Number of clients session is attached to" -- 2.20.1