tmux
它能做什么
它指导 AI 智能体读取 tmux 会话的输出,并向其发送输入,尤其适用于已在运行的交互式工具。它适合把长时间运行的终端任务放在 tmux 中的开发者。
适用场景
- ✓你想查看某个正在运行的终端工具正在输出什么的时候。
- ✓tmux 会话中的某个工具正在等待输入、需要回复的时候。
- ✓你需要启动、重命名或关闭某个 tmux 会话的时候。
技能链接
https://github.com/openclaw/openclaw/blob/main/skills/tmux/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请查看名为 worker 的 tmux 会话,告诉我它现在正在输出什么。”
每周 5 个新技能,1 分钟读完。
工作原理
技能列出会话和窗格,读取最近的输出,并在你要求时发送文字或按键。在批准或选择任何内容之前,它会确认自己理解了提示。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
tmux
Use for existing interactive tmux sessions. For one-shot commands, use normal shell. For new non-interactive background jobs, use background execution.
Basics
tmux ls
tmux list-windows -t shared
tmux list-panes -t shared:0
tmux capture-pane -t shared:0.0 -p
tmux capture-pane -t shared:0.0 -p -S -
Target format: session:window.pane, e.g. shared:0.0.
Send input
Literal text, then Enter:
tmux send-keys -t shared:0.0 -l -- "Please continue"
tmux send-keys -t shared:0.0 Enter
Special keys:
tmux send-keys -t shared:0.0 C-c
tmux send-keys -t shared:0.0 C-d
tmux send-keys -t shared:0.0 Escape
Use -l -- for arbitrary text. Split text and Enter to avoid paste/newline surprises.
Sessions
tmux new-session -d -s worker
tmux rename-session -t old new
tmux kill-session -t worker
Prompt checks
tmux capture-pane -t worker-3 -p | tail -20
tmux capture-pane -t worker-3 -p | rg "proceed|permission|Yes|No|❯"
Approve/select only when the prompt is understood:
tmux send-keys -t worker-3 -l -- "y"
tmux send-keys -t worker-3 Enter
Helpers
scripts/find-sessions.sh: discover sessions.scripts/wait-for-text.sh: wait until captured pane contents contain text.
wait-for-text.sh searches echoed input and scrollback as well as process output. For command completion, use a unique marker whose full text is split across arguments in the command sent to tmux:
nonce="$(od -An -N8 -tx1 /dev/urandom | tr -d ' \n')"
marker="OPENCLAW_DONE_${nonce}"
tmux send-keys -t shared:0.0 -l -- "sleep 4; printf '%s%s\n' 'OPENCLAW_DONE_' '$nonce'"
tmux send-keys -t shared:0.0 Enter
scripts/wait-for-text.sh -t shared:0.0 -p "$marker" -F -T 30
The echoed command never contains the complete marker, and the nonce prevents an older completion line from matching.
Notes
capture-pane -pprints to stdout for scripts.-S -captures full scrollback.- tmux sessions persist across SSH disconnects.
常见问题
它会不经询问就发送命令吗?
只有在提示被理解、操作明确时,它才会批准提示。
tmux 是用来执行一次性命令的吗?
不是。执行一次性命令时,普通的 shell 更简单;tmux 适用于已有的交互式会话。
它能等待任务完成吗?
可以。辅助脚本可以等待窗格显示某些文字,不过使用唯一的标记效果最好。
详情
作者的原始描述
Control tmux sessions/panes for interactive CLIs: list, capture output, send keys, paste text, monitor prompts.
repo: openclaw/openclaw
热度
- GitHub 星标
- 394k
- 排名
- #86
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
discord-user-post
394k让你的智能体通过 Discord 桌面应用,以你的身份发送你已批准的消息,并在发送前确认具体频道。
discrawl
394k让你的智能体搜索和总结本地保存的 Discord 消息档案,查看档案的新旧程度,并阅读私信。
gitcrawl
394k让你的智能体搜索已保存的 GitHub 议题和拉取请求档案,将重复内容归类,并在 GitHub 上核实它们的当前状态。
graincrawl
394k让你的智能体搜索已保存的 Granola 会议记录和转写稿,查看它们的新旧程度,并统计某段时间内的数量。