mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-16 18:31:40 +01:00
Add command line arguments to set the account_key/session_names
-k account_key -n session_name -r session_name_ro
This commit is contained in:
parent
c63c8fbf90
commit
c78198dc59
1
server.c
1
server.c
@ -203,6 +203,7 @@ server_start(struct event_base *base, int lockfd, char *lockfile)
|
||||
|
||||
#ifdef TMATE
|
||||
tmate_set_editor_mode();
|
||||
tmate_init_boot_options();
|
||||
#endif
|
||||
start_cfg();
|
||||
|
||||
|
35
tmux.c
35
tmux.c
@ -201,6 +201,30 @@ find_home(void)
|
||||
return (home);
|
||||
}
|
||||
|
||||
#ifdef TMATE
|
||||
static char *account_key;
|
||||
static char *session_name;
|
||||
static char *session_name_ro;
|
||||
|
||||
void tmate_init_boot_options(void)
|
||||
{
|
||||
if (account_key)
|
||||
tmate_exec_cmd_args(4, (const char *[]){"set-option", "-g", "tmate-account-key", account_key});
|
||||
if (session_name)
|
||||
tmate_exec_cmd_args(4, (const char *[]){"set-option", "-g", "tmate-session-name", session_name});
|
||||
if (session_name_ro)
|
||||
tmate_exec_cmd_args(4, (const char *[]){"set-option", "-g", "tmate-session-name-ro", session_name_ro});
|
||||
|
||||
free(account_key);
|
||||
free(session_name);
|
||||
free(session_name_ro);
|
||||
|
||||
account_key = NULL;
|
||||
session_name = NULL;
|
||||
session_name_ro = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@ -231,7 +255,7 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
label = path = NULL;
|
||||
while ((opt = getopt(argc, argv, "2c:CdFf:lL:qS:uUVv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "2c:CdFf:lL:qS:uUVvk:n:r:")) != -1) {
|
||||
switch (opt) {
|
||||
case '2':
|
||||
flags |= CLIENT_256COLOURS;
|
||||
@ -276,6 +300,15 @@ main(int argc, char **argv)
|
||||
log_add_level();
|
||||
unsetenv("TMUX");
|
||||
break;
|
||||
case 'k':
|
||||
account_key = xstrdup(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
session_name = xstrdup(optarg);
|
||||
break;
|
||||
case 'r':
|
||||
session_name_ro = xstrdup(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user