mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-25 16:19:02 +01:00
Add a -o option to set-option to prevent setting an option already set, from
Thiago Padilha.
This commit is contained in:
parent
69a8d64716
commit
be13479f09
@ -63,8 +63,8 @@ struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_q *,
|
|||||||
|
|
||||||
const struct cmd_entry cmd_set_option_entry = {
|
const struct cmd_entry cmd_set_option_entry = {
|
||||||
"set-option", "set",
|
"set-option", "set",
|
||||||
"agqst:uw", 1, 2,
|
"agoqst:uw", 1, 2,
|
||||||
"[-agsquw] [-t target-session|target-window] option [value]",
|
"[-agosquw] [-t target-session|target-window] option [value]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -73,8 +73,8 @@ const struct cmd_entry cmd_set_option_entry = {
|
|||||||
|
|
||||||
const struct cmd_entry cmd_set_window_option_entry = {
|
const struct cmd_entry cmd_set_window_option_entry = {
|
||||||
"set-window-option", "setw",
|
"set-window-option", "setw",
|
||||||
"agqt:u", 1, 2,
|
"agoqt:u", 1, 2,
|
||||||
"[-agqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -151,6 +151,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
|
if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
|
if (!args_has(args, 'q'))
|
||||||
|
cmdq_print(cmdq, "already set: %s", optstr);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@ -227,6 +232,11 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char* optstr,
|
|||||||
cmdq_error(cmdq, "empty value");
|
cmdq_error(cmdq, "empty value");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
|
||||||
|
if (!args_has(args, 'q'))
|
||||||
|
cmdq_print(cmdq, "already set: %s", optstr);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
options_set_string(oo, optstr, "%s", valstr);
|
options_set_string(oo, optstr, "%s", valstr);
|
||||||
if (!args_has(args, 'q')) {
|
if (!args_has(args, 'q')) {
|
||||||
cmdq_info(cmdq, "set option: %s -> %s", optstr,
|
cmdq_info(cmdq, "set option: %s -> %s", optstr,
|
||||||
|
6
tmux.1
6
tmux.1
@ -1996,7 +1996,7 @@ abc123
|
|||||||
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 agqsuw
|
.Op Fl agoqsuw
|
||||||
.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
|
||||||
@ -2025,6 +2025,10 @@ options.
|
|||||||
It is not possible to unset a global option.
|
It is not possible to unset a global option.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
.Fl o
|
||||||
|
flag prevents setting an option that is already set.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
.Fl q
|
.Fl q
|
||||||
flag suppresses the informational message (as if the
|
flag suppresses the informational message (as if the
|
||||||
.Ic quiet
|
.Ic quiet
|
||||||
|
Loading…
Reference in New Issue
Block a user