libtmux Reference MCP Search
On this page

server.Server.watch

View as Markdown

Module
server
Declared in
Server
Package
@libtmux/libtmux
Source
packages/libtmux/src/server.ts
watch ( options : : WatchOptions ) TmuxEventStream
method [source]
method [source]
watch

Stream tmux's control-mode notifications until the stream is disposed.

A snapshot answers what is true now; this answers what changed. The stream holds one tmux -C attach-session process for its lifetime, so it reports events without polling and without a command per read. That process is a tmux-visible attached client until the stream closes; it affects client listings, attachment state, hooks, and related policy.

tmux sends a control client no pane output until it attaches, so this attaches to a session; a server with no sessions has nothing to watch.

Name that session with target when reading pane output. Structural notifications reach the client wherever it attached, but output arrives only for the attached session, and an untargeted watch lands on whichever session tmux considers current. With two sessions on the server that is silence rather than an error.

Examples

await using events = server.watch();
for await (const event of events) {
  if (event.kind === "window-add") console.log(event.windowId);
}

Discussed in Control mode vs one-shot

0 declared, 0 inherited

Esc

Type to search.