Remote-control zellij sessions for interactive CLIs by sending keystrokes and scraping pane output.
Use zellij only when you need an interactive TTY. Prefer exec background mode for long-running, non-interactive tasks.
```bash
DATA_DIR="${CLAWDBOT_ZELLIJ_DATA_DIR:-${TMPDIR:-/tmp}/moltbot-zellij-data}"
mkdir -p "$DATA_DIR"
SESSION=moltbot-python
zellij --data-dir "$DATA_DIR" new-session --session "$SESSION" --layout "default" --detach
zellij --data-dir "$DATA_DIR" run --session "$SESSION" --name repl -- python3 -q
zellij --data-dir "$DATA_DIR" pipe --session "$SESSION" --pane-id 0
```
After starting a session, always print monitor commands:
```
To monitor:
zellij --data-dir "$DATA_DIR" attach --session "$SESSION"
zellij --data-dir "$DATA_DIR" pipe --session "$SESSION" --pane-id 0
```
zellij excels at running multiple coding agents in parallel:
```bash
DATA_DIR="${TMPDIR:-/tmp}/codex-army-data"
for i in 1 2 3 4 5; do
zellij --data-dir "$DATA_DIR" new-session --session "agent-$i" --layout "compact" --detach
done
zellij --data-dir "$DATA_DIR" action --session "agent-1" write-chars --chars "cd /tmp/project1 && codex --yolo 'Fix bug X'\n"
zellij --data-dir "$DATA_DIR" action --session "agent-2" write-chars --chars "cd /tmp/project2 && codex --yolo 'Fix bug Y'\n"
for sess in agent-1 agent-2; do
pane_id=$(zellij --data-dir "$DATA_DIR" list-sessions --long | grep "\"$sess\"" | jq -r '.tabs[0].panes[0].id')
if zellij --data-dir "$DATA_DIR" pipe --session "$sess" --pane-id "$pane_id" | grep -q "❯"; then
echo "$sess: DONE"
else
echo "$sess: Running..."
fi
done
zellij --data-dir "$DATA_DIR" pipe --session "agent-1" --pane-id 0
```
**Tips:**
| Task | tmux | zellij |
|------|------|--------|
| List sessions | `list-sessions` | `list-sessions` |
| Create session | `new-session -d` | `new-session --detach` |
| Attach | `attach -t` | `attach --session` |
| Send keys | `send-keys` | `action write-chars` |
| Capture pane | `capture-pane` | `pipe` |
| Kill session | `kill-session` | `delete-session` |
| Detach | `Ctrl+b d` | `Ctrl+p d` |
`{baseDir}/scripts/wait-for-text.sh` polls a pane for a regex (or fixed string) with a timeout.
```bash
{baseDir}/scripts/wait-for-text.sh -s session -p pane-id -r 'pattern' [-F] [-T 20] [-i 0.5]
```
`{baseDir}/scripts/find-panes.sh` lists panes for a given session.
```bash
{baseDir}/scripts/find-panes.sh -s session [-d data-dir]
```
Leave a review
No reviews yet. Be the first to review this skill!