mirror of
https://github.com/tmux/tmux.git
synced 2025-01-06 15:58:48 +00:00
Add -v to set and setw to show only option value.
This commit is contained in:
parent
7360ff4496
commit
102cb77435
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,8 +745,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;
|
||||
@ -754,13 +754,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);
|
||||
|
8
tmux.1
8
tmux.1
@ -2869,7 +2869,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
|
||||
@ -2885,8 +2885,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
|
||||
@ -2896,6 +2898,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
|
||||
|
11
tmux.h
11
tmux.h
@ -1568,12 +1568,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 */
|
||||
|
Loading…
Reference in New Issue
Block a user