You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add server mode and shell function examples for tmux integration
- Add --port flag requirement for tmux subagent pane spawning
- Add Fish shell function example with automatic port allocation
- Add Bash/Zsh equivalent function example
- Document how subagent panes work (opencode attach flow)
- Add OPENCODE_PORT environment variable documentation
- Add server mode reference section with opencode serve command
Copy file name to clipboardExpand all lines: docs/configurations.md
+120-3Lines changed: 120 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,6 +259,7 @@ Run background subagents in separate tmux panes for **visual multi-agent executi
259
259
260
260
1.**Must run inside tmux**: The feature only activates when OpenCode is already running inside a tmux session
261
261
2.**Tmux installed**: Requires tmux to be available in PATH
262
+
3.**Server mode**: OpenCode must run with `--port` flag to enable subagent pane spawning
262
263
263
264
### How It Works
264
265
@@ -268,17 +269,133 @@ When `tmux.enabled` is `true` and you're inside a tmux session:
268
269
- Panes are automatically closed when the subagent completes
269
270
- Layout is automatically adjusted based on your configuration
270
271
271
-
**Example workflow**:
272
+
### Running OpenCode with Tmux Subagent Support
273
+
274
+
To enable tmux subagent panes, OpenCode must run in **server mode** with the `--port` flag. This starts an HTTP server that subagent panes connect to via `opencode attach`.
275
+
276
+
**Basic setup**:
272
277
```bash
273
278
# Start tmux session
274
279
tmux new -s dev
275
280
276
-
# Run OpenCode inside tmux
277
-
opencode
281
+
# Run OpenCode with server mode (port 4096)
282
+
opencode --port 4096
278
283
279
284
# Now background agents will appear in separate panes
280
285
```
281
286
287
+
**Recommended: Shell Function**
288
+
289
+
For convenience, create a shell function that automatically handles tmux sessions and port allocation. Here's an example for Fish shell:
290
+
291
+
```fish
292
+
# ~/.config/fish/config.fish
293
+
function oc
294
+
set base_name (basename (pwd))
295
+
set path_hash (echo (pwd) | md5 | cut -c1-4)
296
+
set session_name "$base_name-$path_hash"
297
+
298
+
# Find available port starting from 4096
299
+
function __oc_find_port
300
+
set port 4096
301
+
while test $port -lt 5096
302
+
if not lsof -i :$port >/dev/null 2>&1
303
+
echo $port
304
+
return 0
305
+
end
306
+
set port (math $port + 1)
307
+
end
308
+
echo 4096
309
+
end
310
+
311
+
set oc_port (__oc_find_port)
312
+
set -x OPENCODE_PORT $oc_port
313
+
314
+
if set -q TMUX
315
+
# Already inside tmux - just run with port
316
+
opencode --port $oc_port $argv
317
+
else
318
+
# Create tmux session and run opencode
319
+
set oc_cmd "OPENCODE_PORT=$oc_port opencode --port $oc_port $argv; exec fish"
320
+
if tmux has-session -t "$session_name" 2>/dev/null
0 commit comments