One bot owns the chat and delegates coding to persistent tmux sub-agents, using a .done file marker for a reliable handoff (status/wait/result). Includes README + install.sh for one-command setup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# mav-tmux — run a command in the persistent mav tmux session and capture output
|
|
# usage: mav-tmux run "command"
|
|
# mav-tmux read (capture current pane output)
|
|
# mav-tmux clear (clear the pane)
|
|
SESSION="mav"
|
|
|
|
# ensure session exists
|
|
TMUX= tmux has-session -t "$SESSION" 2>/dev/null || TMUX= tmux new-session -d -s "$SESSION"
|
|
|
|
case "${1:-read}" in
|
|
run)
|
|
CMD="${2:?usage: mav-tmux run <command>}"
|
|
MARKER="__DONE_$(date +%s%N)__"
|
|
TMUX= tmux send-keys -t "$SESSION" "$CMD; echo $MARKER" Enter
|
|
# wait for marker
|
|
for i in $(seq 1 60); do
|
|
sleep 0.5
|
|
OUT=$(TMUX= tmux capture-pane -t "$SESSION" -p 2>/dev/null)
|
|
if echo "$OUT" | grep -q "$MARKER"; then
|
|
echo "$OUT" | sed "/$MARKER/d" | sed '/^$/d' | tail -30
|
|
break
|
|
fi
|
|
done
|
|
;;
|
|
read)
|
|
TMUX= tmux capture-pane -t "$SESSION" -p 2>/dev/null
|
|
;;
|
|
clear)
|
|
TMUX= tmux send-keys -t "$SESSION" "clear" Enter
|
|
;;
|
|
*)
|
|
echo "usage: mav-tmux run <cmd> | read | clear"
|
|
;;
|
|
esac
|