From 9781946a70d0bde07abdeca3221b5cb4a31b6f3c Mon Sep 17 00:00:00 2001 From: Nicolas Viennot Date: Tue, 5 Nov 2019 21:32:21 -0500 Subject: [PATCH] Show initial message in copy mode --- tmate-msg.c | 20 ++++++++++++++++++++ tmate-session.c | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/tmate-msg.c b/tmate-msg.c index a47f9e4d..4ee0a5de 100644 --- a/tmate-msg.c +++ b/tmate-msg.c @@ -50,6 +50,24 @@ static void tmate_status_message_client(struct client *c, const char *message) recalculate_sizes(); } +static void tmate_status_message_session(const char *message) +{ + if (tmate_foreground) + return; + + struct session *s; + s = RB_MIN(sessions, &sessions); + if (!s) { + cfg_add_cause("%s", message); + return; + } + + struct window_pane *wp; + wp = s->curw->window->active; + if (wp->mode == &window_copy_mode) + window_copy_add(wp, "%s", message); +} + void __tmate_status_message(const char *fmt, va_list ap) { struct client *c; @@ -63,6 +81,8 @@ void __tmate_status_message(const char *fmt, va_list ap) tmate_status_message_client(c, message); } + tmate_status_message_session(message); + free(message); } diff --git a/tmate-session.c b/tmate-session.c index b9f03a8e..0c07a758 100644 --- a/tmate-session.c +++ b/tmate-session.c @@ -190,6 +190,11 @@ void tmate_session_start(void) * - While we are parsing the config file, we need to be able to * serialize it, and so we need a worker encoder. */ + if (!tmate_foreground) { + cfg_add_cause("%s", "To see these messages again, run: tmate show-messages"); + cfg_add_cause("%s", "-----------------------------------------------------"); + } + send_authorized_keys(); tmate_write_ready(); lookup_and_connect();