How to get notified of activity or silence in a tmux window?

By Romain Dorgueil

Short answer

# ~/.tmux.conf
setw -g monitor-activity on    # flag the window when any output appears
setw -g monitor-silence 30     # flag it after 30 s with no output (0 = off)
set  -g visual-activity on     # also print a status message, not just the flag

Start a build or a long job in one window, switch away, and tmux highlights that window in the status bar the moment something happens. monitor-activity reacts to new output, monitor-silence reacts to output stopping for N seconds, which is the better signal for “the job finished”.

Details

Both options are per window and read the inactive windows for you, so the point is to set them and keep working in another window. When the condition triggers, the window gets a flag in the status bar; with visual-activity on tmux also shows a one-line message.

Pick the option that matches what you are waiting for. monitor-activity fires on the first byte of output, which is noisy for a chatty process but perfect for “tell me when this quiet thing says anything”. monitor-silence fires after the window produces nothing for the number of seconds you set, so a compile or a test run that prints continuously and then stops will flag itself when it goes quiet. Set the value back to 0 to turn silence monitoring off.

A third, related option is monitor-bell, which flags the window when a program rings the terminal bell. Unlike the other two it is on by default, so a process that emits a bell already marks its window without any config.

Verified on tmux 3.2a. Defaults: monitor-activity off, monitor-silence 0, visual-activity off, monitor-bell on. After turning monitoring on, sending output to an inactive window sets that window’s activity flag while it stays in the background.

Related