diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 16:15:53 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 16:15:53 +0000 |
commit | 0ae5f147d915b5047a3711e505d37b2771200bba (patch) | |
tree | eea8f8cff54048b754ff02b72b9b2fbc1ca05bd5 /usr.bin | |
parent | 0f6af9b309a721a449999dd82b632cd320d8093b (diff) |
Add -v to set and setw to show only option value.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-show-options.c | 26 | ||||
-rw-r--r-- | usr.bin/tmux/options-table.c | 14 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 10 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 13 |
5 files changed, 41 insertions, 26 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 047dec0341c..aee1cba2ecb 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.57 2012/07/11 07:10:15 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.58 2013/03/21 16:15:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -234,7 +234,7 @@ cmd_set_option_set(struct cmd *self, struct cmd_ctx *ctx, if (o == NULL) return (-1); - s = options_table_print_entry(oe, o); + s = options_table_print_entry(oe, o, 0); if (!args_has(args, 'q')) ctx->info(ctx, "set option: %s -> %s", oe->name, s); return (0); diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c index 514790a40c5..fa5f27fc938 100644 --- a/usr.bin/tmux/cmd-show-options.c +++ b/usr.bin/tmux/cmd-show-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-show-options.c,v 1.16 2012/07/11 07:10:15 nicm Exp $ */ +/* $OpenBSD: cmd-show-options.c,v 1.17 2013/03/21 16:15:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -31,8 +31,8 @@ enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_options_entry = { "show-options", "show", - "gst:w", 0, 1, - "[-gsw] [-t target-session|target-window] [option]", + "gst:vw", 0, 1, + "[-gsvw] [-t target-session|target-window] [option]", 0, NULL, NULL, @@ -41,8 +41,8 @@ const struct cmd_entry cmd_show_options_entry = { const struct cmd_entry cmd_show_window_options_entry = { "show-window-options", "showw", - "gt:", 0, 1, - "[-g] " CMD_TARGET_WINDOW_USAGE " [option]", + "gvt:", 0, 1, + "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]", 0, NULL, NULL, @@ -98,14 +98,22 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) } if ((o = options_find1(oo, oe->name)) == NULL) return (CMD_RETURN_NORMAL); - optval = options_table_print_entry(oe, o); - ctx->print(ctx, "%s %s", oe->name, optval); + optval = options_table_print_entry(oe, o, + args_has(self->args, 'v')); + if (args_has(self->args, 'v')) + ctx->print(ctx, "%s", optval); + else + ctx->print(ctx, "%s %s", oe->name, optval); } else { for (oe = table; oe->name != NULL; oe++) { if ((o = options_find1(oo, oe->name)) == NULL) continue; - optval = options_table_print_entry(oe, o); - ctx->print(ctx, "%s %s", oe->name, optval); + optval = options_table_print_entry(oe, o, + args_has(self->args, 'v')); + if (args_has(self->args, 'v')) + ctx->print(ctx, "%s", optval); + else + ctx->print(ctx, "%s %s", oe->name, optval); } } diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index b8b1216368d..ae7efd7f5a3 100644 --- a/usr.bin/tmux/options-table.c +++ b/usr.bin/tmux/options-table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-table.c,v 1.32 2013/01/17 00:11:22 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.33 2013/03/21 16:15:52 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -746,8 +746,8 @@ options_table_populate_tree( /* Print an option using its type from the table. */ const char * -options_table_print_entry( - const struct options_table_entry *oe, struct options_entry *o) +options_table_print_entry(const struct options_table_entry *oe, + struct options_entry *o, int no_quotes) { static char out[BUFSIZ]; const char *s; @@ -755,13 +755,17 @@ options_table_print_entry( *out = '\0'; switch (oe->type) { case OPTIONS_TABLE_STRING: - xsnprintf(out, sizeof out, "\"%s\"", o->str); + if (no_quotes) + xsnprintf(out, sizeof out, "%s", o->str); + else + xsnprintf(out, sizeof out, "\"%s\"", o->str); break; case OPTIONS_TABLE_NUMBER: xsnprintf(out, sizeof out, "%lld", o->num); break; case OPTIONS_TABLE_KEY: - xsnprintf(out, sizeof out, "%s", key_string_lookup_key(o->num)); + xsnprintf(out, sizeof out, "%s", + key_string_lookup_key(o->num)); break; case OPTIONS_TABLE_COLOUR: s = colour_tostring(o->num); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 1bd957fe0d0..218630e0b46 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.316 2013/03/21 16:14:50 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.317 2013/03/21 16:15:52 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -2865,7 +2865,7 @@ If this option is set, searches will wrap around the end of the pane contents. The default is on. .El .It Xo Ic show-options -.Op Fl gsw +.Op Fl gsvw .Op Fl t Ar target-session | Ar target-window .Op Ar option .Xc @@ -2881,8 +2881,10 @@ otherwise the session options for Global session or window options are listed if .Fl g is used. +.Fl v +shows only the option value, not the name. .It Xo Ic show-window-options -.Op Fl g +.Op Fl gv .Op Fl t Ar target-window .Op Ar option .Xc @@ -2892,6 +2894,8 @@ List the window options or a single option for or the global window options if .Fl g is used. +.Fl v +shows only the option value, not the name. .El .Sh FORMATS Certain commands accept the diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 67975bde0a4..fc07a636688 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.378 2013/03/21 16:12:10 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.379 2013/03/21 16:15:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1572,12 +1572,11 @@ long long options_get_number(struct options *, const char *); extern const struct options_table_entry server_options_table[]; extern const struct options_table_entry session_options_table[]; extern const struct options_table_entry window_options_table[]; -void options_table_populate_tree( - const struct options_table_entry *, struct options *); -const char *options_table_print_entry( - const struct options_table_entry *, struct options_entry *); -int options_table_find( - const char *, const struct options_table_entry **, +void options_table_populate_tree(const struct options_table_entry *, + struct options *); +const char *options_table_print_entry(const struct options_table_entry *, + struct options_entry *, int); +int options_table_find(const char *, const struct options_table_entry **, const struct options_table_entry **); /* job.c */ |