diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-06-04 14:29:34 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-06-04 14:29:34 +0000 |
commit | d22be6a0edaff63dca3fca1507303d08eccf60e1 (patch) | |
tree | 77b3b4103c03271ee5c0892a1cccb1e961ac4da6 /usr.bin | |
parent | 061f0434bb3326606f34c662cff009bc5d4b80a7 (diff) |
Make unsetting a global option restore it to the default. Diff lying
around for a while, I have forgotten who suggested it :-/.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 21 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 14 |
2 files changed, 21 insertions, 14 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 33f2b675512..980c10edcfc 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.74 2015/04/24 23:17:11 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.75 2015/06/04 14:29:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index bd5a4c17bab..1250615aa26 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.432 2015/06/04 11:43:51 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.433 2015/06/04 14:29:33 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -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 |