zterm

Notifications

zterm can raise a desktop notification in three cases: a program in a pane asks for one, something new waits on you in Needs you, and a command finishes. The first two are on by default, the third is off.

A program asks

A script asks for a notification with the escape sequence most terminals implement, or with iTerm2's shorter one:

printf '\e]777;notify;Deploy;failed on staging\a'   # title, then body
printf '\e]9;build finished\a'                      # body only

The words always appear on the pane, as a small pill at the top left of its text, until you press a key or click in that pane. That pill is the pane's own chrome, so it shows whatever the settings say about banners.

What the system banner says depends on who opened the pane. A pane you opened yourself, with a window, a tab or a split, posts a banner titled with the pane's name, or its title if it has no name, and carrying the script's words: Deploy: failed on staging. Any other pane, one an agent spawned, or one a shell made for itself with zterm perform split_right, posts a banner saying only that the pane sent a notification. The words are still on the pane. That keeps text chosen by a program you didn't start off your lock screen, which is the same line zterm draws around a pane writing to your clipboard.

One banner per pane per five seconds. A pane that asks twenty times in a second gets one banner, and the pill shows the last words. The rest are dropped rather than queued, so a runaway loop can't bank an hour of stale banners for you to wake up to.

Something new waits on you

When something joins the panel's Needs you list, zterm posts one banner for it, such as sumac needs permission or aspen has a question for you. Under the title is the question, or the ticket it is about. Each item posts once. If it leaves the list and comes back later, it posts again.

Items already on the list when zterm starts post nothing. zterm reads the list when the panel reads it, so with the panel hidden in every window no banner comes. The minimal panel still reads it.

Clicking the banner focuses the agent's pane when this zterm holds it. Otherwise it opens the item's pull request, or its ticket on the dashboard.

A command finishes

zterm knows when a command starts and stops only if your shell says so, by sourcing one of the shell/osc133.* snippets that ship with zterm. With that in place it can notify you when a long command is done, which is off by default:

[notifications]
command_finished = true
min_duration_ms = 10000

min_duration_ms is the floor. Anything that finishes faster notifies nobody, because a banner for every ls teaches you to dismiss banners unread.

A command in the pane you're looking at posts no banner, because you watched it finish. That pane has to be the focused one in zterm's frontmost window. Switch to another pane or another app and the banner comes.

Clicking a banner

Clicking a program's banner or a finished command's brings zterm to the front and focuses the pane that sent it, switching to its window and tab. If the pane has moved to another tab since, the click finds it there. If it has closed, the click does nothing.

The bell

A program rings the bell by printing BEL (\a, byte 7). Agent tools do this when they finish or need an answer. zterm makes no sound and does not flash the pane.

When the pane that rang is not the one you are typing in, its chip on the tab bar gets an amber !. The mark stays until you focus that pane. If the zterm window is behind another window, zterm also asks for your attention once: on macOS the dock icon bounces once, on Windows the taskbar button flashes. A program that rings many times in a row marks the chip once and asks once.

A bell from the pane you are typing in does nothing.

There is no setting for the bell.

A program reports its status

A program can tell zterm that it is working, waiting on you, done or failed, with OSC 7501. A blocked pane gets an amber ! on its tab's chip that stays until the program moves on, and the pill turns red and lists what it waits for. If the program is an agent the panel lists, it also joins Needs you and posts one banner. An error shows a red ! until you focus the pane. Working and done show nothing on the tab bar, except on an agent's tile. A pane on another machine in your mesh shows its status the same way, when that machine runs this version of zterm or later. INTEGRATION.md has the sequence.

Turning them off

[notifications]
on_request = false

With that, a program asking for a notification gets no banner. The pill on the pane still appears.

[notifications]
needs_banner = false

With that, Needs you posts no banners. The list in the panel is unchanged.

Something that looks like a fault

On macOS the system shows no banner while zterm is the frontmost application. Switch to another app before the script fires, or watch for the pill.

Where to go next

  • Settings reference: the [notifications] keys.
  • INTEGRATION.md: the sequences in full, the shell snippets, what the parser does with the text, and the zterm:// links that raise a pane.