Auto-spawn tmux panes for OpenCode subagent sessions — when OpenCode creates a child session, this plugin splits a new tmux pane and attaches it automatically.
When OpenCode fires a session.created event for a child session (one with a parentID), the plugin:
- Splits a new tmux pane horizontally
- Runs
opencode attach <serverUrl> --session <id> --dir <dir>in it - Applies your configured layout
- Closes the pane when the session goes idle (if
autoClose: true) - Polls periodically as a fallback to catch missed events
- tmux ≥ 3.0 installed and in
PATH - OpenCode must be running inside a tmux session (the plugin is a no-op otherwise)
opencodebinary must be inPATH(for theattachcommand in spawned panes)
OpenCode must be started as a server with an explicit port so the plugin knows the serverUrl to pass to opencode attach in spawned panes:
opencode --port 3000Without a port, the plugin cannot construct the serverUrl and the opencode attach <serverUrl> --session <id> command in new tmux panes will fail.
bun add @floschl/opencode-tmuxRegister the plugin in your opencode.json (global ~/.config/opencode/opencode.json or project-local):
{
"plugin": ["@floschl/opencode-tmux"]
}Note: OpenCode validates
opencode.jsonagainst its own strict schema and rejects unknown keys. Plugin config lives in a separate file — do not add"tmux": { ... }toopencode.json.
Create opencode-tmux.json with the plugin's settings. Keys are flat (no nesting):
Global (~/.config/opencode/opencode-tmux.json):
{
"layout": "main-vertical",
"mainPaneSize": 60,
"autoClose": true
}Project-local (either path works; <project>/opencode-tmux.json takes precedence):
<project>/opencode-tmux.json<project>/.opencode/opencode-tmux.json
Project-local config overrides global config. Unset keys fall back to defaults.
All keys go directly in opencode-tmux.json (flat, no nesting).
| Key | Type | Default | Description |
|---|---|---|---|
layout |
string | "main-vertical" |
tmux layout: main-vertical, main-horizontal, tiled, even-horizontal, even-vertical |
mainPaneSize |
number | 60 |
Main pane size as percentage (10–90). Used with main-vertical / main-horizontal layouts |
autoClose |
boolean | true |
Close pane automatically when session goes idle |
pollIntervalMs |
number | 2000 |
How often (ms) to poll session status as a fallback |
sessionTimeoutMs |
number | 600000 |
Max session lifetime in ms (10 min default) before force-close |
Project-level opencode-tmux.json overrides global config.
| Event | Action |
|---|---|
session.created (child only) |
Spawn new tmux pane with opencode attach |
session.status → idle |
Close pane (if autoClose: true) |
session.status → busy |
Re-spawn pane if session is known but pane was closed |
session.deleted |
Close pane unconditionally |
| Poll tick | Close idle / timed-out / long-missing sessions |
Set OPENCODE_TMUX_DEBUG=1 to enable verbose stderr logging:
OPENCODE_TMUX_DEBUG=1 opencode- tmux only — no support for other terminal multiplexers
- Child sessions only — top-level sessions (no
parentID) are ignored - Requires OpenCode to be started from within an active tmux session
- The
opencode attachcommand must be available in the spawned pane'sPATH