Replace the notification system with events. Events can carry a payload of

additional payload (to reduce problems with lifetime of objects) and are
delivered to one or more event sinks. This is more powerful and reduces the
complex dependencies between control mode and hooks. Events are now used for
hooks, control mode notifications and for monitors (set-hook -B).

wait-for can now wait for an event to fire (-E flag, with -F to for filter),
with -v to print the payload, as well as listing (-l) waiting clients on an
event and forcing one to wake (-w).

A few additional hooks are also now available (pane-created, pane-resized, etc)
and some of the existing ones have additional format variables available.
This commit is contained in:
nicm
2026-07-10 13:38:45 +00:00
parent 1508bec957
commit d29aa12117
153 changed files with 2543 additions and 1787 deletions

101
tmux.1
View File

@@ -1,4 +1,4 @@
.\" $OpenBSD$
.\" $OpenBSD: tmux.1,v 1.1131 2026/07/10 13:38:45 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
.Dd $Mdocdate: July 10 2026 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -6323,11 +6323,7 @@ For example, this could be used to write to a log file:
set\-hook \-g command\-error "run\-shell \\"echo 'a tmux command failed' >>/tmp/log\\""
.Ed
.Pp
All the notifications listed in the
.Sx CONTROL MODE
section are hooks (without any arguments), except
.Ic %exit .
The following additional hooks are available:
The following hooks are available in addition to after hooks:
.Bl -tag -width "XXXXXXXXXXXXXXXXXXXXXX"
.It alert\-activity
Run when a window has activity.
@@ -6346,11 +6342,11 @@ Run when a client becomes the latest active client of its session.
.It client\-attached
Run when a client is attached.
.It client\-detached
Run when a client is detached
Run when a client is detached.
.It client\-focus\-in
Run when focus enters a client
Run when focus enters a client.
.It client\-focus\-out
Run when focus exits a client
Run when focus exits a client.
.It client\-resized
Run when a client is resized.
.It client\-session\-changed
@@ -6361,6 +6357,10 @@ Run when a client switches to a light theme.
Run when a client switches to a dark theme.
.It command\-error
Run when a command fails.
.It marked\-pane\-changed
Run when the marked pane is set or cleared.
.It pane\-created
Run when a pane is created or respawned.
.It pane\-died
Run when the program running in a pane exits, but
.Ic remain\-on\-exit
@@ -6375,20 +6375,38 @@ option is on.
Run when the focus exits a pane, if the
.Ic focus\-events
option is on.
.It pane\-mode\-changed
Run when a pane changes mode.
.It pane\-mode\-entered
Run when a pane enters a mode.
.It pane\-mode\-exited
Run when a pane exits a mode.
.It pane\-prompt\-closed
Run when a prompt in a pane is closed.
.It pane\-prompt\-opened
Run when a prompt is opened in a pane.
.It pane\-resized
Run when a pane is resized.
.It pane\-set\-clipboard
Run when the terminal clipboard is set using the
.Xr xterm 1
escape sequence.
.It session\-created
Run when a new session created.
.It pane\-title\-changed
Run when a pane title is changed.
.It session\-closed
Run when a session closed.
Run when a session is closed.
.It session\-created
Run when a new session is created.
.It session\-renamed
Run when a session is renamed.
.It session\-window\-changed
Run when a session changes its active window.
.It window\-layout\-changed
Run when a window layout is changed.
.It window\-linked
Run when a window is linked into a session.
.It window\-pane\-changed
Run when a window changes its active pane.
.It window\-renamed
Run when a window is renamed.
.It window\-resized
@@ -6396,6 +6414,10 @@ Run when a window is resized.
This may be after the
.Ar client\-resized
hook is run.
.It window\-unzoomed
Run when a window is unzoomed.
.It window\-zoomed
Run when a window is zoomed.
.It window\-unlinked
Run when a window is unlinked from a session.
.El
@@ -6403,13 +6425,15 @@ Run when a window is unlinked from a session.
Hooks are managed with these commands:
.Bl -tag -width Ds
.It Xo Ic set\-hook
.Op Fl agpRuw
.Op Fl agpERuw
.Op Fl B Ar name:what:format
.Op Fl t Ar target\-pane
.Ar hook\-name
.Op Ar command
.Xc
Without
.Fl E
or
.Fl R ,
sets (or with
.Fl u
@@ -6450,6 +6474,14 @@ the subscription named by
is removed.
.Pp
With
.Fl E ,
fire the user event named
.Ar hook\-name .
.Ar hook\-name
must begin with
.Ql @ .
.Pp
With
.Fl R ,
run
.Ar hook\-name
@@ -8560,8 +8592,10 @@ or the current pane if omitted) after the command finishes.
If the command fails, the exit status is also displayed.
.Tg wait
.It Xo Ic wait\-for
.Op Fl L | S | U
.Ar channel
.Op Fl ELSUlv
.Op Fl F Ar format
.Op Fl w Ar waiter
.Ar name
.Xc
.D1 Pq alias: Ic wait
When used without options, prevents the client from exiting until woken using
@@ -8574,6 +8608,41 @@ is used, the channel is locked and any clients that try to lock the same
channel are made to wait until the channel is unlocked with
.Ic wait\-for
.Fl U .
.Pp
With
.Fl E ,
.Nm
waits for the next event with
.Ar name .
Events include hook and notification names, and user
.Ql @
events generated by
.Ic set-hook
.Fl E
or
.Ic set-hook
.Fl B .
If
.Fl F
is given,
.Ar format
must also be true.
If
.Fl v
is given, event payload keys are printed (whether or not
.Ar format
is true).
.Pp
.Fl l
list the waiters for
.Ar name
and
.Fl w
wakes
.Ar waiter
on
.Ar name
immediately.
.El
.Sh EXIT MESSAGES
When a