Script tab titles
Tab titles are not all built in: a Lua plugin can derive them, and its answers render as the tabs' names. A plugins/titles.lua like this
local dropterm = require('dropterm')
-- A plugin that names tabs the way the old `Shell` mode did
dropterm.tab_title(function(tab)
return (tab.title ~= '' and tab.title) or nil
end)
gives every tab its shell's own OSC title, the way the old Shell title mode did. There is no mode to set: a provider is asked as soon as a script registers it, and a tab reads Terminal N until a provider names it. The plugins page covers the runtime - the lazy host, hot reload, the timeout machinery - and the trust model: a plugin is your own config executing as you, complete standard library, no sandbox.
The provider contract
dropterm.tab_title(handler) registers the one provider - globally, not one per tab: the handler derives every tab's title from the ctx it receives. A later registration replaces an earlier one - one dropterm: log line each time, the replacement named as such. Titles are a stable, keybind-independent identity.
The handler receives { tab, title }, and two more keys when the tab has them:
| Key | Meaning |
|---|---|
tab | the tab's id as an opaque number: stable for the tab's life, the same id the terminal events carry, meaningful only to correlate |
title | the raw OSC 0/2 report, the empty string when the tab has none (the provider decides what an empty title means) |
cwd | the tab's working directory, when the engine reported one (on Windows, the shell's own folder report - a silent shell leaves the key absent) |
profile | the profile's name (a profile's name is its id), when the tab launched under one |
It returns a string - the tab's new title, the empty string honored verbatim - or nil, no opinion: the tab falls back to its Terminal N default. A handler that raises costs one log line and the tab keeps the title it already had.
When tabs are re-asked
Asks are change-gated, never per-tick. With no provider registered, nobody is asked. Every tab shows its default. A tab is asked when its row differs from the one its last ask sent: its title report moved (a shell setting or clearing its title), its directory or profile changed, or it spawned. A provider's arrival asks every tab once, in one batched dispatch - not one trip per tab. A provider arrives when a load or a reload first names one: at launch, when the plugins/ dir was already there before the app started (the boot that wakes the host - the load's sync report names the provider).
Background tabs are asked on their own changes, never on the active tab's - all titles must resolve (the strip renders every tab), each on its own material.
The stale ladder
The strip never blocks on a script: the ask crosses to the host and the answer lands on a later tick, so a tab keeps its last resolved title until then. Per tab:
- no answer yet (or a
nil) - theTerminal Ndefault; - an answer - that text, until the next answer;
- a raise or a trip past the soft bound (100 ms) - the prior title keeps rendering, one log line, and the next answer lands when it comes.
A reload that registers the provider again is no arrival: nothing is cleared and nothing is asked, and the titles keep what they show. A reload into no provider clears the seat. The tabs keep their last titles across the gap - never a blank. A later registration is an arrival that asks every tab once.
The rename still wins
A manual rename (the strip's inline rename, a double-click) stays authoritative: title churn and fresh script answers never clobber it. Clearing the rename - committing an empty one - returns to the provider's standing answer at once, never a flicker of the default in between.
One caveat, for a tab a dropterm.tab_rows source fills (filling a tab): the rename changes the tab's name, the source is asked again with it, and the plugin is trusted to show the new name - the rows are its own. The app keeps showing the name on hover, so it is never lost.
Decorating tabs
A second seat decorates the strip without touching its labels: dropterm.tab_chips(handler) receives the tab list, each row { id, title, cwd, profile }, and answers per tab id a badge, a class, and a tip. Several plugins may hold it at once, their answers merged per tab and per key (several sources). The bands page holds the contract; the recipe:
local dropterm = require('dropterm')
-- The strip's decoration source: a badge, a class, a tip; never the label
dropterm.tab_chips(function(tabs)
local out = {}
for _, tab in ipairs(tabs) do
if tab.title == 'ssh' or tab.title:match('^ssh ') then
out[tab.id] = { badge = 'remote', tip = 'A remote shell' }
end
end
return out
end)
A third seat fills a tab's content outright, rows in place of the title: dropterm.tab_rows (filling a tab).