mirror of
https://github.com/tmate-io/tmate.git
synced 2025-06-08 18:57:44 +02: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
|
#ifdef TMATE
|
||||||
tmate_set_editor_mode();
|
tmate_set_editor_mode();
|
||||||
|
tmate_init_boot_options();
|
||||||
#endif
|
#endif
|
||||||
start_cfg();
|
start_cfg();
|
||||||
|
|
||||||
|
35
tmux.c
35
tmux.c
@ -201,6 +201,30 @@ find_home(void)
|
|||||||
return (home);
|
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
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -231,7 +255,7 @@ main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
label = path = NULL;
|
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) {
|
switch (opt) {
|
||||||
case '2':
|
case '2':
|
||||||
flags |= CLIENT_256COLOURS;
|
flags |= CLIENT_256COLOURS;
|
||||||
@ -276,6 +300,15 @@ main(int argc, char **argv)
|
|||||||
log_add_level();
|
log_add_level();
|
||||||
unsetenv("TMUX");
|
unsetenv("TMUX");
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
account_key = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
session_name = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
session_name_ro = xstrdup(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -1551,6 +1551,7 @@ extern struct timeval start_time;
|
|||||||
extern const char *socket_path;
|
extern const char *socket_path;
|
||||||
#ifdef TMATE
|
#ifdef TMATE
|
||||||
extern int tmate_foreground;
|
extern int tmate_foreground;
|
||||||
|
void tmate_init_boot_options(void);
|
||||||
#endif
|
#endif
|
||||||
const char *getshell(void);
|
const char *getshell(void);
|
||||||
int checkshell(const char *);
|
int checkshell(const char *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user