Auto-Renaming tmux Windows for AI Coding Agents
I run multiple Droid and Claude Code instances in tmux, each in its own window. The problem: every Droid window starts named “droid” and every Claude Code window shows its version number. With 5+ agent windows open, I can’t tell which is which from the status bar.
So I wrote a script that watches for these windows, reads their pane content, and uses AI to generate a short descriptive name.
How It Works
The script runs in a loop every 30 seconds. It:
- Lists all tmux windows in the current session
- Finds windows named “droid” or matching a version pattern like
1.0.43(Claude Code’s default) - Captures the pane content after the tool’s header
- Sends it to
droid execto generate a 1-3 word name - Renames the window
The key decisions I made:
- Wait for enough content — if there are fewer than 10 non-empty lines after the header, the agent probably just started. Skip it and check again next loop.
- Prefix with project name — I maintain a map of working directory paths to short prefixes (
hbfor this blog,bluefor TheBlue,wmfor WindowManager, etc.). The generated name always starts with the project prefix so I can instantly see which project an agent is working on. - Exclude path words — the AI prompt excludes words already in the project path to avoid repetitive names.
- Notify on unknown repos — if an agent is running in an unrecognized directory, I get a macOS notification so I can add it to the map.
The Path Map
The script resolves symlinks and maps directories to prefixes:
const PATH_TO_PREFIX: Record<string, string> = {
"~/p/hboon.com/hboon.com": "hb",
"~/p/myog/myog.social": "og",
"~/p/theblue/theblue.social": "blue",
"~/p/WindowManager": "wm",
"~/Documents/Scripts": "scripts",
// ...
};
So a Droid window working on this blog might get renamed to hb post draft, and one working on TheBlue might become blue fix auth.
The Naming Prompt
The script sends the captured pane content to droid exec with a prompt like this:
Based on this terminal content, generate a 1-3 word window name
that hints at what this window is for. The first word MUST be "hb".
Do NOT use any of these words (they are already in the path): hboon, com.
Output ONLY the name, nothing else.
Content:
<pane content>
The prefix and excluded words are filled in dynamically based on the working directory. The excluded words prevent repetitive names — no point naming a window “hb hboon blog” when “hb” already tells me which project it is.
Detecting the Header
Both Droid and Claude Code print headers when they start. The script needs to skip past these to get the actual conversation content.
For Droid, it looks for the Current folder: line and starts after it. For Claude Code, it finds the version string (e.g., Claude Code v1.0.43) and starts after that line. If the header has scrolled out of view, it falls back to reading from the beginning of the buffer.
Running It
I run it with Bun as a background process:
bun ~/scripts/tmux-rename-droid-windows.ts
I keep it in a dedicated tmux window. It logs what it’s doing:
Starting tmux window renamer...
Checking every 30 seconds for windows named 'droid' or matching version pattern (Claude Code)
Processing window 3 (name: droid)
Renaming window 3 to: hb post draft
Processing window 5 (name: 1.0.43)
Renaming window 5 to: dash fix api
The Result
Before — every agent window is just “droid” or a version number:

After — each window has a descriptive name with project prefix:

I can now glance at the status bar and know exactly what each agent is doing and which project it’s in.
The full script is about 200 lines of TypeScript — easy to generate with a prompt or two. It uses Bun’s shell API for tmux commands and droid exec for the AI naming. Nothing fancy, but it saves me from constantly switching windows just to remember which agent is doing what.