49 lines
2.2 KiB
Markdown
49 lines
2.2 KiB
Markdown
# How to use tmux control mode? (tmuxai.dev)
|
|||
|
|
|
||
|
|
## Metadata
|
||
|
|
|
||
|
|
| Field | Value |
|
||
|
|
|---|---|
|
||
|
|
| Institute | Molodetz Institute — Research & Retrieval Division |
|
||
|
|
| Subject | shell-multiplexer-auto-attach |
|
||
|
|
| Document type | Source Dossier |
|
||
|
|
| Tier | 1 |
|
||
|
|
| Source title | How to use tmux control mode? |
|
||
|
|
| Source URL | https://tmuxai.dev/tmux-control-mode/ |
|
||
|
|
| Source publisher / author | tmuxai.dev |
|
||
|
|
| Source type | blog post |
|
||
|
|
| Source date (published) | Unknown — not stated |
|
||
|
|
| Date researched | 2026-10-09 |
|
||
|
|
| Researched by | tai (agent), model: Claude Sonnet 5, on behalf of retoor |
|
||
|
|
| Research method | web search synthesis |
|
||
|
|
| Confidence | Medium |
|
||
|
|
| Status | Active |
|
||
|
|
|
||
|
|
## Summary
|
||
|
|
|
||
|
|
Explains tmux's control mode (`-C`/`-CC`): a text-only protocol where a client writes newline-terminated tmux commands to stdin, and each command's output is framed between a `%begin` line (with timestamp and command number) and a closing `%end` (success) or `%error` (failure). Asynchronous events arrive as `%`-prefixed notifications that never appear inside an output block.
|
||
|
|
|
||
|
|
## Key findings
|
||
|
|
|
||
|
|
- Deterministic framing (`%begin`...`%end`/`%error`) means a program can reliably know where one command's output stops, which plain `send-keys`+`capture-pane` polling cannot guarantee on its own.
|
||
|
|
- Notifications are guaranteed not to interleave inside a command's output block — a real concurrency guarantee useful for building a parser.
|
||
|
|
- `-CC` additionally disables echo, which matters for programmatic clients that don't want their own commands echoed back.
|
||
|
|
|
||
|
|
## Pros / strengths
|
||
|
|
|
||
|
|
- Gives the exact framing contract (`%begin`/`%end`/`%error`) needed to write a correct parser for a control-mode client, which is the structured alternative to screen-scraping `capture-pane` output.
|
||
|
|
|
||
|
|
## Cons / limitations / caveats
|
||
|
|
|
||
|
|
- A blog post, not tmux's own specification — cross-check framing details against the tmux source or man page before depending on them in production code.
|
||
|
|
|
||
|
|
## Relevance to tai
|
||
|
|
|
||
|
|
This is the mechanism for the "events" requirement in the proposal — control mode's notification stream is how a tai layer would receive pane-output/window-change events asynchronously rather than polling `capture-pane` in a loop.
|
||
|
|
|
||
|
|
## Changelog
|
||
|
|
|
||
|
|
| Date | Change |
|
||
|
|
|---|---|
|
||
|
|
| 2026-10-09 | Initial dossier created. |
|