mirror of
https://github.com/tmate-io/tmate.git
synced 2025-04-27 12:49:43 +02:00
Show message when restarting shell
This commit is contained in:
parent
c71307ed5c
commit
442143cd90
@ -989,6 +989,14 @@ const struct options_table_entry options_table[] = {
|
|||||||
.scope = OPTIONS_TABLE_SERVER,
|
.scope = OPTIONS_TABLE_SERVER,
|
||||||
.default_str = ""
|
.default_str = ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ .name = "tmate-foreground-restart",
|
||||||
|
.type = OPTIONS_TABLE_NUMBER,
|
||||||
|
.scope = OPTIONS_TABLE_SERVER,
|
||||||
|
.minimum = 0,
|
||||||
|
.maximum = 1,
|
||||||
|
.default_num = 1
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ .name = NULL }
|
{ .name = NULL }
|
||||||
|
40
session.c
40
session.c
@ -207,6 +207,36 @@ session_free(__unused int fd, __unused short events, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void maybe_restart_session(void)
|
||||||
|
{
|
||||||
|
int fg_restart = options_get_number(global_options, "tmate-foreground-restart");
|
||||||
|
if (!fg_restart)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* throttle restarts. This is a blocking sleep. It's
|
||||||
|
* simpler than using a timer, but fairly harmless
|
||||||
|
* from a blocking perspective.
|
||||||
|
*/
|
||||||
|
usleep(500*1000);
|
||||||
|
next_session_id = 0;
|
||||||
|
run_initial_client_cmd();
|
||||||
|
|
||||||
|
tmate_info("Shell exited. Shell restarted");
|
||||||
|
|
||||||
|
struct session *s;
|
||||||
|
s = RB_MIN(sessions, &sessions);
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct window_pane *wp;
|
||||||
|
wp = s->curw->window->active;
|
||||||
|
window_pane_set_mode(wp, &window_copy_mode);
|
||||||
|
window_copy_init_for_output(wp);
|
||||||
|
window_copy_add(wp, "%s", "Shell exited. Shell restarted.");
|
||||||
|
window_copy_add(wp, "%s", "Note: press the following sequence to disconnect from SSH: <Enter>~.");
|
||||||
|
}
|
||||||
|
|
||||||
/* Destroy a session. */
|
/* Destroy a session. */
|
||||||
void
|
void
|
||||||
session_destroy(struct session *s)
|
session_destroy(struct session *s)
|
||||||
@ -239,15 +269,7 @@ session_destroy(struct session *s)
|
|||||||
|
|
||||||
#ifdef TMATE
|
#ifdef TMATE
|
||||||
if (tmate_foreground && !server_exit) {
|
if (tmate_foreground && !server_exit) {
|
||||||
tmate_info("Shell exited, restarting");
|
maybe_restart_session();
|
||||||
/*
|
|
||||||
* throttle restarts. This is a blocking sleep.
|
|
||||||
* It's simpler than using a timer, but fairly harmless
|
|
||||||
* from a blocking perspective.
|
|
||||||
*/
|
|
||||||
usleep(500*1000);
|
|
||||||
next_session_id = 0;
|
|
||||||
run_initial_client_cmd();
|
|
||||||
} else {
|
} else {
|
||||||
tmate_info("Session closed");
|
tmate_info("Session closed");
|
||||||
tmate_write_fin();
|
tmate_write_fin();
|
||||||
|
Loading…
Reference in New Issue
Block a user