aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2015-06-04 14:29:33 +0000
committernicm <nicm>2015-06-04 14:29:33 +0000
commit4a6c06d6a981d05c5ab3dbc7a365ff740fbb7feb (patch)
treee6cc87952f20905e67dc951a03b8994ca22597ac
parenta863834574ec02b87ff0e7245ef31f0d4543ab34 (diff)
downloadrtmux-4a6c06d6a981d05c5ab3dbc7a365ff740fbb7feb.tar.gz
rtmux-4a6c06d6a981d05c5ab3dbc7a365ff740fbb7feb.tar.bz2
rtmux-4a6c06d6a981d05c5ab3dbc7a365ff740fbb7feb.zip
Make unsetting a global option restore it to the default. Diff lying
around for a while, I have forgotten who suggested it :-/.
-rw-r--r--cmd-set-option.c19
-rw-r--r--tmux.112
2 files changed, 19 insertions, 12 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 83d31b93..77c7d7c2 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -266,16 +266,25 @@ cmd_set_option_unset(struct cmd *self, struct cmd_q *cmdq,
{
struct args *args = self->args;
- if (args_has(args, 'g')) {
- cmdq_error(cmdq, "can't unset global option: %s", oe->name);
- return (-1);
- }
if (value != NULL) {
cmdq_error(cmdq, "value passed to unset option: %s", oe->name);
return (-1);
}
- options_remove(oo, oe->name);
+ if (args_has(args, 'g') || oo == &global_options) {
+ switch (oe->type) {
+ case OPTIONS_TABLE_STRING:
+ options_set_string(oo, oe->name, "%s", oe->default_str);
+ break;
+ case OPTIONS_TABLE_STYLE:
+ options_set_style(oo, oe->name, oe->default_str, 0);
+ break;
+ default:
+ options_set_number(oo, oe->name, oe->default_num);
+ break;
+ }
+ } else
+ options_remove(oo, oe->name);
return (0);
}
diff --git a/tmux.1 b/tmux.1
index 015e5ee7..e479afbe 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2273,21 +2273,19 @@ 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.
+is given, the global session or window option is set.
The
.Fl u
flag unsets an option, so a session inherits the option from the global
-options.
-It is not possible to unset a global option.
+options (or with
+.Fl g ,
+restores a global option to the default).
.Pp
The
.Fl o
-flag prevents setting an option that is already set.
-.Pp
-The
+flag prevents setting an option that is already set and
.Fl q
flag suppresses errors about unknown options.
.Pp