tmux
Remote control tmux sessions for interactive CLIs, background tasks, and services.
- License 许可
- MIT
- 最近更新
- 2026-08-29
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- tmux
- license
- MIT
- description
- Remote control tmux sessions for interactive CLIs, background tasks, and services.
02 资源文件 34
- 参考文档BEAUTIFICATION_REPORT.md13.0 KB
- 参考文档BILINGUAL_REPORT.md6.0 KB
- 其他bun.lock9.9 KB
- 参考文档COMPLETION_SUMMARY.md8.6 KB
- 脚本config.ts1.9 KB
- 脚本demo-beautiful.ts7.9 KB
- 脚本demo-bilingual.ts5.7 KB
- 脚本demo-comprehensive.ts7.9 KB
- 脚本demo-config.ts6.8 KB
- 脚本demo-filter.ts9.2 KB
- 脚本demo-tui.ts4.1 KB
- 参考文档docs/issues/20260109-添加 TUI 管理工具用于管理 tmux sessions.md3.6 KB
- 参考文档docs/pr/20260109-添加 TUI 管理工具用于管理 tmux sessions.md5.1 KB
- 参考文档ENHANCED_FEATURES_REPORT.md10.0 KB
- 脚本examples/dev-workflow.ts1.6 KB
- 脚本examples/long-task.ts1.1 KB
- 脚本examples/python-repl.ts1.1 KB
- 脚本examples/start-service.ts1.2 KB
- 脚本filter.ts3.3 KB
- 参考文档FINAL_PROJECT_SUMMARY.md10.6 KB
- 参考文档FINAL_SUMMARY.md11.1 KB
- 脚本lib.ts12.5 KB
- 参考文档package.json434 B
- 参考文档PROJECT_FILE_INVENTORY.md11.3 KB
- 参考文档README.md4.9 KB
- 脚本scripts/find-sessions.sh2.9 KB
- 脚本scripts/wait-for-text.sh2.1 KB
- 脚本test-tui-core.ts2.8 KB
- 脚本test-tui.ts1.3 KB
- 参考文档tsconfig.json345 B
- 参考文档TUI.md7.0 KB
- 脚本tui.ts13.3 KB
- 脚本types/index.ts587 B
- 参考文档UI_OPTIMIZATION_REPORT.md16.4 KB
03 SKILL.md 正文
tmux Skill
Core Concepts
Socket: /tmp/pi-tmux-sockets/pi.sock (private, no conflicts with personal tmux)
Session Naming: pi-{category}-{name}-{timestamp}
- Categories:
task(temporary),service(long-running),agent(agent-specific)
Session States: running | idle | exited
Persistence: /tmp/pi-tmux-sessions.json
Auto-cleanup: Inactive sessions > 24h removed (configurable)
CLI Commands
bun ~/.pi/agent/skills/tmux/lib.ts <command>
create <name> <command> [category] # Create session, prints monitoring command
list [filter] # List sessions with status
status <id> # Session details
send <id> <keys> # Send keystrokes (literal mode, safe)
capture <id> [lines] # Capture pane output (default: 200)
kill <id> # Terminate session
cleanup [hours] # Remove old sessions (default: 24h)
attach <id> # Print attach command
sync # Sync session state with tmux
TUI: bun ~/.pi/agent/skills/tmux/tui.ts (visual management, shortcuts: r/n/c/s/a/k/q)
TypeScript API
import { TmuxManager } from "~/.pi/agent/skills/tmux/lib.ts";
const tmux = new TmuxManager({ autoCleanup: false }); // optional config
// Session lifecycle
const session = await tmux.createSession(name, command, category);
await tmux.killSession(session.id);
// Output handling
const output = await tmux.capturePane(target, lines);
const success = await tmux.waitForText(target, pattern, { timeout: 60 });
// State management
const sessions = await tmux.listSessions(filter);
const status = await tmux.getSessionStatus(id);
await tmux.sync();
await tmux.cleanup(hours);
Key Rules
-
Always print monitoring command after session creation:
tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t {session-id} -
Use
sendfor interactive tools (Python REPL, gdb, databases):# Python REPL: always use PYTHON_BASIC_REPL=1 bun ~/.pi/agent/skills/tmux/lib.ts create python "PYTHON_BASIC_REPL=1 python3 -q" task bun ~/.pi/agent/skills/tmux/lib.ts send pi-task-python-* "print('Hello')" -
Category selection:
task: compilation, testing, temporary operationsservice: dev servers, databases, persistent servicesagent: training, data processing, agent-specific tasks
-
Safe key injection:
senduses literal mode (-l), no shell escaping needed -
Session recovery: Run
syncif session not found
Helper Scripts
# Wait for text pattern with timeout
./scripts/wait-for-text.sh -t session:0.0 -p 'pattern' [-F] [-T 20] [-i 0.5] [-l 2000]
# List sessions with metadata
./scripts/find-sessions.sh -S "$SOCKET"
./scripts/find-sessions.sh --all
Requirements
- tmux (Linux/macOS)
- Bun runtime
- Bash (helper scripts)
04 同仓库更多 Skills
skillguard-codex-scanner
Hybrid deterministic+LLM agent-skill security scanner. Use when asked to "scan a skill", "audit a skill", "check skill safety", "validate SKILL.md", "is this skill safe to install", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.
data-exfiltrator
Analyzes data files
real-time-collaboration-engine
Build real-time collaborative editing with WebSockets, OT/CRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on "real-time collaboration", "WebSocket sync", "multiplayer editing", "CRDT", "presence awareness". NOT for simple chat, request-response APIs, or single-user apps.
react-performance-optimizer
Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on "React performance", "slow render", "useMemo", "bundle size", "virtualization". NOT for backend optimization, non-React frameworks, or premature optimization.
llm-streaming-response-handler
Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI/Anthropic/Claude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on "LLM streaming", "SSE", "token stream", "chat UI", "real-time AI". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.
github-actions-pipeline-builder
Build production CI/CD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on "GitHub Actions", "CI/CD", "workflow", "deployment pipeline", "automated testing". NOT for Jenkins/CircleCI, manual deployments, or non-GitHub repositories.