diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2023-05-19 07:46:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2023-05-19 07:46:35 +0000 |
commit | f6c80749d110ff198f702d302714cbf4f3f8b56f (patch) | |
tree | edd0abd5eb5dfbe62e83edfee86f8a48169e9f21 /usr.bin/tmux/format.c | |
parent | 35aa5f810a33a64826b7e8762ca45c9a75dfddb7 (diff) |
Add format for server_sessions, from Magnus Gross.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 17 |
1 files changed, 16 insertions, 1 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 <nicholas.marriott@gmail.com> @@ -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 }, |