mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 08:33:17 +01:00
Add "server options" which are server-wide and not bound to a session or
window. Set and displayed with "set -s" and "show -s". Currently the only option is "quiet" (like command-line -q, allowing it to be set from .tmux.conf), but others will come along.
This commit is contained in:
parent
6311bd119e
commit
a4c9a80dac
@ -70,8 +70,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
tim = ctime(&start_time);
|
tim = ctime(&start_time);
|
||||||
*strchr(tim, '\n') = '\0';
|
*strchr(tim, '\n') = '\0';
|
||||||
ctx->print(ctx, "pid %ld, started %s", (long) getpid(), tim);
|
ctx->print(ctx, "pid %ld, started %s", (long) getpid(), tim);
|
||||||
ctx->print(ctx, "socket path %s, debug level %d%s",
|
ctx->print(
|
||||||
socket_path, debug_level, be_quiet ? ", quiet" : "");
|
ctx, "socket path %s, debug level %d", socket_path, debug_level);
|
||||||
if (uname(&un) == 0) {
|
if (uname(&un) == 0) {
|
||||||
ctx->print(ctx, "system is %s %s %s %s",
|
ctx->print(ctx, "system is %s %s %s %s",
|
||||||
un.sysname, un.release, un.version, un.machine);
|
un.sysname, un.release, un.version, un.machine);
|
||||||
|
@ -48,8 +48,8 @@ void cmd_set_option_choice(struct cmd_ctx *,
|
|||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
"[-aguw] [-t target-session|target-window] option [value]",
|
"[-agsuw] [-t target-session|target-window] option [value]",
|
||||||
CMD_ARG12, "aguw",
|
CMD_ARG12, "agsuw",
|
||||||
NULL,
|
NULL,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_set_option_exec,
|
cmd_set_option_exec,
|
||||||
@ -73,6 +73,10 @@ const char *set_option_bell_action_list[] = {
|
|||||||
"none", "any", "current", NULL
|
"none", "any", "current", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct set_option_entry set_option_table[] = {
|
||||||
|
{ "quiet", SET_OPTION_FLAG, 0, 0, NULL },
|
||||||
|
};
|
||||||
|
|
||||||
const struct set_option_entry set_session_option_table[] = {
|
const struct set_option_entry set_session_option_table[] = {
|
||||||
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
|
||||||
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
|
||||||
@ -172,7 +176,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int i;
|
u_int i;
|
||||||
int try_again;
|
int try_again;
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'w')) {
|
if (cmd_check_flag(data->chflags, 's')) {
|
||||||
|
oo = &global_options;
|
||||||
|
table = set_option_table;
|
||||||
|
} else if (cmd_check_flag(data->chflags, 'w')) {
|
||||||
table = set_window_option_table;
|
table = set_window_option_table;
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
oo = &global_w_options;
|
oo = &global_w_options;
|
||||||
|
@ -31,8 +31,8 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
"show-options", "show",
|
||||||
"[-gw] [-t target-session|target-window]",
|
"[-gsw] [-t target-session|target-window]",
|
||||||
0, "gw",
|
0, "gsw",
|
||||||
cmd_target_init,
|
cmd_target_init,
|
||||||
cmd_target_parse,
|
cmd_target_parse,
|
||||||
cmd_show_options_exec,
|
cmd_show_options_exec,
|
||||||
@ -52,7 +52,10 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
const struct set_option_entry *entry;
|
const struct set_option_entry *entry;
|
||||||
const char *optval;
|
const char *optval;
|
||||||
|
|
||||||
if (cmd_check_flag(data->chflags, 'w')) {
|
if (cmd_check_flag(data->chflags, 's')) {
|
||||||
|
oo = &global_options;
|
||||||
|
table = set_option_table;
|
||||||
|
} else if (cmd_check_flag(data->chflags, 'w')) {
|
||||||
table = set_window_option_table;
|
table = set_window_option_table;
|
||||||
if (cmd_check_flag(data->chflags, 'g'))
|
if (cmd_check_flag(data->chflags, 'g'))
|
||||||
oo = &global_w_options;
|
oo = &global_w_options;
|
||||||
|
@ -224,7 +224,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
if (be_quiet)
|
if (options_get_number(&global_options, "quiet"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -640,7 +640,7 @@ server_client_msg_info(struct cmd_ctx *ctx, const char *fmt, ...)
|
|||||||
struct msg_print_data data;
|
struct msg_print_data data;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (be_quiet)
|
if (options_get_number(&global_options, "quiet"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
85
tmux.1
85
tmux.1
@ -151,8 +151,9 @@ signal may be sent to the
|
|||||||
.Nm
|
.Nm
|
||||||
server process to recreate it.
|
server process to recreate it.
|
||||||
.It Fl q
|
.It Fl q
|
||||||
Prevent the server sending various informational messages, for example when
|
Set the
|
||||||
window flags are altered.
|
.Ic quiet
|
||||||
|
server option to prevent the server sending various informational messages.
|
||||||
.It Fl S Ar socket-path
|
.It Fl S Ar socket-path
|
||||||
Specify a full alternative path to the server socket.
|
Specify a full alternative path to the server socket.
|
||||||
If
|
If
|
||||||
@ -1209,13 +1210,26 @@ or for normal mode without.
|
|||||||
The appearance and behaviour of
|
The appearance and behaviour of
|
||||||
.Nm
|
.Nm
|
||||||
may be modified by changing the value of various options.
|
may be modified by changing the value of various options.
|
||||||
There are two types of option:
|
There are three types of option:
|
||||||
|
.Em server options ,
|
||||||
.Em session options
|
.Em session options
|
||||||
and
|
and
|
||||||
.Em window options .
|
.Em window options .
|
||||||
.Pp
|
.Pp
|
||||||
Each individual session may have a set of session options, and there is a
|
The
|
||||||
separate set of global session options.
|
.Nm
|
||||||
|
server has a set of global options which do not apply to any particular
|
||||||
|
window or session.
|
||||||
|
These are altered with the
|
||||||
|
.Ic set-option
|
||||||
|
.Fl s
|
||||||
|
command, or displayed with the
|
||||||
|
.Ic show-options
|
||||||
|
.Fl s
|
||||||
|
command.
|
||||||
|
.Pp
|
||||||
|
In addition, each individual session may have a set of session options, and
|
||||||
|
there is a separate set of global session options.
|
||||||
Sessions which do not have a particular option configured inherit the value
|
Sessions which do not have a particular option configured inherit the value
|
||||||
from the global session options.
|
from the global session options.
|
||||||
Session options are set or unset with the
|
Session options are set or unset with the
|
||||||
@ -1223,7 +1237,7 @@ Session options are set or unset with the
|
|||||||
command and may be listed with the
|
command and may be listed with the
|
||||||
.Ic show-options
|
.Ic show-options
|
||||||
command.
|
command.
|
||||||
The available session options are listed under the
|
The available server and session options are listed under the
|
||||||
.Ic set-option
|
.Ic set-option
|
||||||
command.
|
command.
|
||||||
.Pp
|
.Pp
|
||||||
@ -1241,31 +1255,44 @@ command.
|
|||||||
Commands which set options are as follows:
|
Commands which set options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic set-option
|
.It Xo Ic set-option
|
||||||
.Op Fl aguw
|
.Op Fl agsuw
|
||||||
.Op Fl t Ar target-session | Ar target-window
|
.Op Fl t Ar target-session | Ar target-window
|
||||||
.Ar option Ar value
|
.Ar option Ar value
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic set )
|
.D1 (alias: Ic set )
|
||||||
Set a session option.
|
Set a window option with
|
||||||
|
.Fl w
|
||||||
|
(equivalent to the
|
||||||
|
.Ic set-window-option
|
||||||
|
command),
|
||||||
|
a server option with
|
||||||
|
.Fl s ,
|
||||||
|
otherwise a session option.
|
||||||
|
.Pp
|
||||||
|
If
|
||||||
|
.Fl g
|
||||||
|
is specified, the global session or window option is set.
|
||||||
With
|
With
|
||||||
.Fl a ,
|
.Fl a ,
|
||||||
and if the option expects a string,
|
and if the option expects a string,
|
||||||
.Ar value
|
.Ar value
|
||||||
is appended to the existing setting.
|
is appended to the existing setting.
|
||||||
If
|
|
||||||
.Fl g
|
|
||||||
is specified, the global session option is set.
|
|
||||||
The
|
The
|
||||||
.Fl u
|
.Fl u
|
||||||
flag unsets an option, so a session inherits the option from the global
|
flag unsets an option, so a session inherits the option from the global
|
||||||
options - it is not possible to unset a global option.
|
options.
|
||||||
|
It is not possible to unset a global option.
|
||||||
.Pp
|
.Pp
|
||||||
With
|
Available window options are listed under
|
||||||
.Fl w ,
|
.Ic set-window-option .
|
||||||
this command is equivalent to
|
.Pp
|
||||||
.Ic set-window-option
|
Available server options are:
|
||||||
with
|
.Bl -tag -width Ds
|
||||||
.Ar target-window .
|
.It Ic quiet
|
||||||
|
Enable of disable the display of various informational messages (see also the
|
||||||
|
.Fl q
|
||||||
|
command line flag).
|
||||||
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Available session options are:
|
Available session options are:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
@ -1850,21 +1877,21 @@ as Shift, Alt or Ctrl.
|
|||||||
The default is off.
|
The default is off.
|
||||||
.El
|
.El
|
||||||
.It Xo Ic show-options
|
.It Xo Ic show-options
|
||||||
.Op Fl gw
|
.Op Fl gsw
|
||||||
.Op Fl t Ar target-session | Ar target-window
|
.Op Fl t Ar target-session | Ar target-window
|
||||||
.Xc
|
.Xc
|
||||||
.D1 (alias: Ic show )
|
.D1 (alias: Ic show )
|
||||||
Show the session options for
|
Show the window options with
|
||||||
.Ar target session ,
|
|
||||||
or the global session options with
|
|
||||||
.Fl g .
|
|
||||||
.Pp
|
|
||||||
If
|
|
||||||
.Fl w
|
.Fl w
|
||||||
is used, this command is equivalent to
|
(equivalent to
|
||||||
.Ic show-window-options
|
.Ic show-window-options ),
|
||||||
with
|
the server options with
|
||||||
.Ar target-window .
|
.Fl s ,
|
||||||
|
otherwise the session options for
|
||||||
|
.Ar target session .
|
||||||
|
Global session or window options are listed if
|
||||||
|
.Fl g
|
||||||
|
is used.
|
||||||
.It Xo Ic show-window-options
|
.It Xo Ic show-window-options
|
||||||
.Op Fl g
|
.Op Fl g
|
||||||
.Op Fl t Ar target-window
|
.Op Fl t Ar target-window
|
||||||
|
12
tmux.c
12
tmux.c
@ -36,12 +36,12 @@ extern char *malloc_options;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *cfg_file;
|
char *cfg_file;
|
||||||
|
struct options global_options; /* server options */
|
||||||
struct options global_s_options; /* session options */
|
struct options global_s_options; /* session options */
|
||||||
struct options global_w_options; /* window options */
|
struct options global_w_options; /* window options */
|
||||||
struct environ global_environ;
|
struct environ global_environ;
|
||||||
|
|
||||||
int debug_level;
|
int debug_level;
|
||||||
int be_quiet;
|
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
char *socket_path;
|
char *socket_path;
|
||||||
int login_shell;
|
int login_shell;
|
||||||
@ -222,14 +222,14 @@ main(int argc, char **argv)
|
|||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
enum msgtype msg;
|
enum msgtype msg;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct options *so, *wo;
|
struct options *oo, *so, *wo;
|
||||||
struct keylist *keylist;
|
struct keylist *keylist;
|
||||||
struct msg_command_data cmddata;
|
struct msg_command_data cmddata;
|
||||||
char *s, *shellcmd, *path, *label, *home, *cause;
|
char *s, *shellcmd, *path, *label, *home, *cause;
|
||||||
char cwd[MAXPATHLEN], **var;
|
char cwd[MAXPATHLEN], **var;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
int opt, flags, cmdflags = 0;
|
int opt, flags, quiet, cmdflags = 0;
|
||||||
short events;
|
short events;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -268,7 +268,7 @@ main(int argc, char **argv)
|
|||||||
label = xstrdup(optarg);
|
label = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
be_quiet = 1;
|
quiet = 1;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
@ -314,6 +314,10 @@ main(int argc, char **argv)
|
|||||||
for (var = environ; *var != NULL; var++)
|
for (var = environ; *var != NULL; var++)
|
||||||
environ_put(&global_environ, *var);
|
environ_put(&global_environ, *var);
|
||||||
|
|
||||||
|
options_init(&global_options, NULL);
|
||||||
|
oo = &global_options;
|
||||||
|
options_set_number(oo, "quiet", 0);
|
||||||
|
|
||||||
options_init(&global_s_options, NULL);
|
options_init(&global_s_options, NULL);
|
||||||
so = &global_s_options;
|
so = &global_s_options;
|
||||||
options_set_number(so, "base-index", 0);
|
options_set_number(so, "base-index", 0);
|
||||||
|
2
tmux.h
2
tmux.h
@ -1235,6 +1235,7 @@ struct set_option_entry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* tmux.c */
|
/* tmux.c */
|
||||||
|
extern struct options global_options;
|
||||||
extern struct options global_s_options;
|
extern struct options global_s_options;
|
||||||
extern struct options global_w_options;
|
extern struct options global_w_options;
|
||||||
extern struct environ global_environ;
|
extern struct environ global_environ;
|
||||||
@ -1391,6 +1392,7 @@ extern const char clock_table[14][5][5];
|
|||||||
void clock_draw(struct screen_write_ctx *, int, int);
|
void clock_draw(struct screen_write_ctx *, int, int);
|
||||||
|
|
||||||
/* cmd-set-option.c */
|
/* cmd-set-option.c */
|
||||||
|
extern const struct set_option_entry set_option_table[];
|
||||||
extern const struct set_option_entry set_session_option_table[];
|
extern const struct set_option_entry set_session_option_table[];
|
||||||
extern const struct set_option_entry set_window_option_table[];
|
extern const struct set_option_entry set_window_option_table[];
|
||||||
const char *cmd_set_option_print(
|
const char *cmd_set_option_print(
|
||||||
|
Loading…
Reference in New Issue
Block a user