mirror of
https://github.com/tmux/tmux.git
synced 2024-12-25 02:48:47 +00:00
Add an L modifier like P, W, S to loop over clients. Also fix some long
lines in tmux(1).
This commit is contained in:
parent
7acc8d703d
commit
0bd78b42c0
44
format.c
44
format.c
@ -103,6 +103,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2)
|
|||||||
#define FORMAT_SESSION_NAME 0x8000
|
#define FORMAT_SESSION_NAME 0x8000
|
||||||
#define FORMAT_CHARACTER 0x10000
|
#define FORMAT_CHARACTER 0x10000
|
||||||
#define FORMAT_COLOUR 0x20000
|
#define FORMAT_COLOUR 0x20000
|
||||||
|
#define FORMAT_CLIENTS 0x40000
|
||||||
|
|
||||||
/* Limit on recursion. */
|
/* Limit on recursion. */
|
||||||
#define FORMAT_LOOP_LIMIT 100
|
#define FORMAT_LOOP_LIMIT 100
|
||||||
@ -3747,7 +3748,7 @@ format_build_modifiers(struct format_expand_state *es, const char **s,
|
|||||||
cp++;
|
cp++;
|
||||||
|
|
||||||
/* Check single character modifiers with no arguments. */
|
/* Check single character modifiers with no arguments. */
|
||||||
if (strchr("labcdnwETSWP<>", cp[0]) != NULL &&
|
if (strchr("labcdnwETSWPL<>", cp[0]) != NULL &&
|
||||||
format_is_end(cp[1])) {
|
format_is_end(cp[1])) {
|
||||||
format_add_modifier(&list, count, cp, 1, NULL, 0);
|
format_add_modifier(&list, count, cp, 1, NULL, 0);
|
||||||
cp++;
|
cp++;
|
||||||
@ -4075,6 +4076,40 @@ format_loop_panes(struct format_expand_state *es, const char *fmt)
|
|||||||
return (value);
|
return (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Loop over clients. */
|
||||||
|
static char *
|
||||||
|
format_loop_clients(struct format_expand_state *es, const char *fmt)
|
||||||
|
{
|
||||||
|
struct format_tree *ft = es->ft;
|
||||||
|
struct client *c = ft->client;
|
||||||
|
struct cmdq_item *item = ft->item;
|
||||||
|
struct format_tree *nft;
|
||||||
|
struct format_expand_state next;
|
||||||
|
char *expanded, *value;
|
||||||
|
size_t valuelen;
|
||||||
|
|
||||||
|
value = xcalloc(1, 1);
|
||||||
|
valuelen = 1;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
|
format_log(es, "client loop: %s", c->name);
|
||||||
|
nft = format_create(c, item, 0, ft->flags);
|
||||||
|
format_defaults(nft, c, ft->s, ft->wl, ft->wp);
|
||||||
|
format_copy_state(&next, es, 0);
|
||||||
|
next.ft = nft;
|
||||||
|
expanded = format_expand1(&next, fmt);
|
||||||
|
format_free(nft);
|
||||||
|
|
||||||
|
valuelen += strlen(expanded);
|
||||||
|
value = xrealloc(value, valuelen);
|
||||||
|
|
||||||
|
strlcat(value, expanded, valuelen);
|
||||||
|
free(expanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (value);
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
format_replace_expression(struct format_modifier *mexp,
|
format_replace_expression(struct format_modifier *mexp,
|
||||||
struct format_expand_state *es, const char *copy)
|
struct format_expand_state *es, const char *copy)
|
||||||
@ -4349,6 +4384,9 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen,
|
|||||||
case 'P':
|
case 'P':
|
||||||
modifiers |= FORMAT_PANES;
|
modifiers |= FORMAT_PANES;
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
modifiers |= FORMAT_CLIENTS;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (fm->size == 2) {
|
} else if (fm->size == 2) {
|
||||||
if (strcmp(fm->modifier, "||") == 0 ||
|
if (strcmp(fm->modifier, "||") == 0 ||
|
||||||
@ -4405,6 +4443,10 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen,
|
|||||||
value = format_loop_panes(es, copy);
|
value = format_loop_panes(es, copy);
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (modifiers & FORMAT_CLIENTS) {
|
||||||
|
value = format_loop_clients(es, copy);
|
||||||
|
if (value == NULL)
|
||||||
|
goto fail;
|
||||||
} else if (modifiers & FORMAT_WINDOW_NAME) {
|
} else if (modifiers & FORMAT_WINDOW_NAME) {
|
||||||
value = format_window_name(es, copy);
|
value = format_window_name(es, copy);
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
|
68
tmux.1
68
tmux.1
@ -466,7 +466,8 @@ and
|
|||||||
.Ic confirm-before ,
|
.Ic confirm-before ,
|
||||||
parse their argument to create a new command which is inserted immediately
|
parse their argument to create a new command which is inserted immediately
|
||||||
after themselves.
|
after themselves.
|
||||||
This means that arguments can be parsed twice or more - once when the parent command (such as
|
This means that arguments can be parsed twice or more - once when the parent
|
||||||
|
command (such as
|
||||||
.Ic if-shell )
|
.Ic if-shell )
|
||||||
is parsed and again when it parses and executes its command.
|
is parsed and again when it parses and executes its command.
|
||||||
Commands like
|
Commands like
|
||||||
@ -884,8 +885,8 @@ may consist entirely of the token
|
|||||||
.Ql {mouse}
|
.Ql {mouse}
|
||||||
(alternative form
|
(alternative form
|
||||||
.Ql = )
|
.Ql = )
|
||||||
to specify the session, window or pane where the most recent mouse event occurred
|
to specify the session, window or pane where the most recent mouse event
|
||||||
(see the
|
occurred (see the
|
||||||
.Sx MOUSE SUPPORT
|
.Sx MOUSE SUPPORT
|
||||||
section)
|
section)
|
||||||
or
|
or
|
||||||
@ -1461,7 +1462,7 @@ requests the clipboard from the client using the
|
|||||||
.Xr xterm 1
|
.Xr xterm 1
|
||||||
escape sequence.
|
escape sequence.
|
||||||
If
|
If
|
||||||
Ar target-pane
|
.Ar target-pane
|
||||||
is given, the clipboard is sent (in encoded form), otherwise it is stored in a
|
is given, the clipboard is sent (in encoded form), otherwise it is stored in a
|
||||||
new paste buffer.
|
new paste buffer.
|
||||||
.Pp
|
.Pp
|
||||||
@ -1574,7 +1575,8 @@ server, if not already running, without creating any sessions.
|
|||||||
.Pp
|
.Pp
|
||||||
Note that as by default the
|
Note that as by default the
|
||||||
.Nm
|
.Nm
|
||||||
server will exit with no sessions, this is only useful if a session is created in
|
server will exit with no sessions, this is only useful if a session is created
|
||||||
|
in
|
||||||
.Pa ~/.tmux.conf ,
|
.Pa ~/.tmux.conf ,
|
||||||
.Ic exit-empty
|
.Ic exit-empty
|
||||||
is turned off, or another command is run as part of the same command sequence.
|
is turned off, or another command is run as part of the same command sequence.
|
||||||
@ -1929,7 +1931,8 @@ bind PageUp copy-mode -eu
|
|||||||
.Ed
|
.Ed
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
A number of preset arrangements of panes are available, these are called layouts.
|
A number of preset arrangements of panes are available, these are called
|
||||||
|
layouts.
|
||||||
These may be selected with the
|
These may be selected with the
|
||||||
.Ic select-layout
|
.Ic select-layout
|
||||||
command or cycled with
|
command or cycled with
|
||||||
@ -4595,7 +4598,8 @@ hook and there are a number of hooks not associated with commands.
|
|||||||
.Pp
|
.Pp
|
||||||
Hooks are stored as array options, members of the array are executed in
|
Hooks are stored as array options, members of the array are executed in
|
||||||
order when the hook is triggered.
|
order when the hook is triggered.
|
||||||
Like options different hooks may be global or belong to a session, window or pane.
|
Like options different hooks may be global or belong to a session, window or
|
||||||
|
pane.
|
||||||
Hooks may be configured with the
|
Hooks may be configured with the
|
||||||
.Ic set-hook
|
.Ic set-hook
|
||||||
or
|
or
|
||||||
@ -4778,7 +4782,8 @@ or
|
|||||||
.Ar target-pane
|
.Ar target-pane
|
||||||
in commands bound to mouse key bindings.
|
in commands bound to mouse key bindings.
|
||||||
It resolves to the window or pane over which the mouse event took place
|
It resolves to the window or pane over which the mouse event took place
|
||||||
(for example, the window in the status line over which button 1 was released for a
|
(for example, the window in the status line over which button 1 was released
|
||||||
|
for a
|
||||||
.Ql MouseUp1Status
|
.Ql MouseUp1Status
|
||||||
binding, or the pane over which the wheel was scrolled for a
|
binding, or the pane over which the wheel was scrolled for a
|
||||||
.Ql WheelDownPane
|
.Ql WheelDownPane
|
||||||
@ -4918,13 +4923,16 @@ ignores case.
|
|||||||
For example:
|
For example:
|
||||||
.Ql #{C/r:^Start}
|
.Ql #{C/r:^Start}
|
||||||
.Pp
|
.Pp
|
||||||
Numeric operators may be performed by prefixing two comma-separated alternatives with an
|
Numeric operators may be performed by prefixing two comma-separated alternatives
|
||||||
|
with an
|
||||||
.Ql e
|
.Ql e
|
||||||
and an operator.
|
and an operator.
|
||||||
An optional
|
An optional
|
||||||
.Ql f
|
.Ql f
|
||||||
flag may be given after the operator to use floating point numbers, otherwise integers are used.
|
flag may be given after the operator to use floating point numbers, otherwise
|
||||||
This may be followed by a number giving the number of decimal places to use for the result.
|
integers are used.
|
||||||
|
This may be followed by a number giving the number of decimal places to use for
|
||||||
|
the result.
|
||||||
The available operators are:
|
The available operators are:
|
||||||
addition
|
addition
|
||||||
.Ql + ,
|
.Ql + ,
|
||||||
@ -5054,10 +5062,11 @@ but also expands
|
|||||||
.Xr strftime 3
|
.Xr strftime 3
|
||||||
specifiers.
|
specifiers.
|
||||||
.Ql S:\& ,
|
.Ql S:\& ,
|
||||||
.Ql W:\&
|
.Ql W:\& ,
|
||||||
or
|
|
||||||
.Ql P:\&
|
.Ql P:\&
|
||||||
will loop over each session, window or pane and insert the format once
|
or
|
||||||
|
.Ql L:\&
|
||||||
|
will loop over each session, window, pane or client and insert the format once
|
||||||
for each.
|
for each.
|
||||||
For windows and panes, two comma-separated formats may be given:
|
For windows and panes, two comma-separated formats may be given:
|
||||||
the second is used for the current window or active pane.
|
the second is used for the current window or active pane.
|
||||||
@ -5084,7 +5093,8 @@ will substitute
|
|||||||
with
|
with
|
||||||
.Ql bar
|
.Ql bar
|
||||||
throughout.
|
throughout.
|
||||||
The first argument may be an extended regular expression and a final argument may be
|
The first argument may be an extended regular expression and a final argument
|
||||||
|
may be
|
||||||
.Ql i
|
.Ql i
|
||||||
to ignore case, for example
|
to ignore case, for example
|
||||||
.Ql s/a(.)/\e1x/i:\&
|
.Ql s/a(.)/\e1x/i:\&
|
||||||
@ -5095,7 +5105,7 @@ into
|
|||||||
A different delimiter character may also be used, to avoid collisions with
|
A different delimiter character may also be used, to avoid collisions with
|
||||||
literal slashes in the pattern.
|
literal slashes in the pattern.
|
||||||
For example,
|
For example,
|
||||||
.Ql s|foo/|bar/|:
|
.Ql s|foo/|bar/|:\&
|
||||||
will substitute
|
will substitute
|
||||||
.Ql foo/
|
.Ql foo/
|
||||||
with
|
with
|
||||||
@ -5111,10 +5121,10 @@ When constructing formats,
|
|||||||
.Nm
|
.Nm
|
||||||
does not wait for
|
does not wait for
|
||||||
.Ql #()
|
.Ql #()
|
||||||
commands to finish; instead, the previous result from running the same command is used,
|
commands to finish; instead, the previous result from running the same command
|
||||||
or a placeholder if the command has not been run before.
|
is used, or a placeholder if the command has not been run before.
|
||||||
If the command hasn't exited, the most recent line of output will be used, but the status
|
If the command hasn't exited, the most recent line of output will be used, but
|
||||||
line will not be updated more than once a second.
|
the status line will not be updated more than once a second.
|
||||||
Commands are executed using
|
Commands are executed using
|
||||||
.Pa /bin/sh
|
.Pa /bin/sh
|
||||||
and with the
|
and with the
|
||||||
@ -5415,8 +5425,8 @@ option:
|
|||||||
.Ic list=on
|
.Ic list=on
|
||||||
marks the start of the list;
|
marks the start of the list;
|
||||||
.Ic list=focus
|
.Ic list=focus
|
||||||
is the part of the list that should be kept in focus if the entire list won't fit
|
is the part of the list that should be kept in focus if the entire list won't
|
||||||
in the available space (typically the current window);
|
fit in the available space (typically the current window);
|
||||||
.Ic list=left-marker
|
.Ic list=left-marker
|
||||||
and
|
and
|
||||||
.Ic list=right-marker
|
.Ic list=right-marker
|
||||||
@ -6566,8 +6576,8 @@ and matching
|
|||||||
.Em %end
|
.Em %end
|
||||||
or
|
or
|
||||||
.Em %error
|
.Em %error
|
||||||
have three arguments: an integer time (as seconds from epoch), command number and
|
have three arguments: an integer time (as seconds from epoch), command number
|
||||||
flags (currently not used).
|
and flags (currently not used).
|
||||||
For example:
|
For example:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
%begin 1363006971 2 1
|
%begin 1363006971 2 1
|
||||||
@ -6617,11 +6627,17 @@ sent when the
|
|||||||
.Ar pause-after
|
.Ar pause-after
|
||||||
flag is set.
|
flag is set.
|
||||||
.Ar age
|
.Ar age
|
||||||
is the time in milliseconds for which tmux had buffered the output before it was sent.
|
is the time in milliseconds for which tmux had buffered the output before it
|
||||||
|
was sent.
|
||||||
Any subsequent arguments up until a single
|
Any subsequent arguments up until a single
|
||||||
.Ql \&:
|
.Ql \&:
|
||||||
are for future use and should be ignored.
|
are for future use and should be ignored.
|
||||||
.It Ic %layout-change Ar window-id Ar window-layout Ar window-visible-layout Ar window-flags
|
.It Xo Ic %layout-change
|
||||||
|
.Ar window-id
|
||||||
|
.Ar window-layout
|
||||||
|
.Ar window-visible-layout
|
||||||
|
.Ar window-flags
|
||||||
|
.Xc
|
||||||
The layout of a window with ID
|
The layout of a window with ID
|
||||||
.Ar window-id
|
.Ar window-id
|
||||||
changed.
|
changed.
|
||||||
|
Loading…
Reference in New Issue
Block a user