tmux
Remote control tmux sessions for interactive CLIs, background tasks, and services. Supports sub-tasks, long-running processes, and service management with session persistence and automatic cleanup.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 6
- Forks
- 0
01 前言 Front Matter
- name
- tmux
- license
- MIT
- description
- Remote control tmux sessions for interactive CLIs, background tasks, and services. Supports sub-tasks, long-running processes, and service management with session persistence and automatic cleanup.
02 资源文件 3
- 脚本lib.ts12.4 KB
- 参考文档skill-report.json210.0 KB
- 参考文档tsconfig.json345 B
03 SKILL.md 正文
tmux Skill
Use tmux as a programmable terminal multiplexer for interactive work, background tasks, and service management. Works on Linux and macOS with stock tmux; uses a private socket to avoid interfering with your personal tmux configuration.
Quickstart (isolated socket)
# Create a new session
bun ~/.pi/agent/skills/tmux/lib.ts create my-task "echo 'Hello World'" task
# List all sessions
bun ~/.pi/agent/skills/tmux/lib.ts list
# Capture output
bun ~/.pi/agent/skills/tmux/lib.ts capture pi-task-my-task-20250107-123456
# Kill a session
bun ~/.pi/agent/skills/tmux/lib.ts kill pi-task-my-task-20250107-123456
Socket Convention
- Socket Directory:
${TMPDIR:-/tmp}/pi-tmux-sockets - Default Socket:
/tmp/pi-tmux-sockets/pi.sock - Environment Variable:
PI_TMUX_SOCKET_DIR(optional override)
All Agent sessions use a private socket to avoid conflicts with your personal tmux configuration.
Session Naming
Sessions are named using the pattern: pi-{category}-{name}-{timestamp}
-
Categories:
task: Temporary sub-tasks (compilation, testing)service: Long-running services (dev servers, databases)agent: Agent-specific tasks (training, data processing)
-
Examples:
pi-task-compile-20250107-123456pi-service-dev-server-20250107-123456pi-agent-training-20250107-123456
CLI Commands
Create Session
bun ~/.pi/agent/skills/tmux/lib.ts create <name> <command> [category]
Creates a new tmux session and automatically prints the monitoring command.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts create compile "make clean && make all" task
List Sessions
bun ~/.pi/agent/skills/tmux/lib.ts list [filter]
Lists all sessions with status and last activity time.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts list
bun ~/.pi/agent/skills/tmux/lib.ts list service
Session Status
bun ~/.pi/agent/skills/tmux/lib.ts status <id>
Shows detailed information about a session.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts status pi-task-compile-20250107-123456
Send Keys
bun ~/.pi/agent/skills/tmux/lib.ts send <id> <keys>
Sends keystrokes to a session. Uses literal mode to avoid shell escaping.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts send pi-task-python-20250107-123456 "print('Hello')"
Capture Output
bun ~/.pi/agent/skills/tmux/lib.ts capture <id> [lines]
Captures pane output (default: 200 lines).
Example:
bun ~/.pi/agent/skills/tmux/lib.ts capture pi-task-compile-20250107-123456 500
Kill Session
bun ~/.pi/agent/skills/tmux/lib.ts kill <id>
Terminates a tmux session.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts kill pi-task-compile-20250107-123456
Cleanup Old Sessions
bun ~/.pi/agent/skills/tmux/lib.ts cleanup [hours]
Removes inactive sessions older than the specified age (default: 24 hours).
Example:
bun ~/.pi/agent/skills/tmux/lib.ts cleanup
bun ~/.pi/agent/skills/tmux/lib.ts cleanup 48
Attach to Session
bun ~/.pi/agent/skills/tmux/lib.ts attach <id>
Prints the command to attach to a session interactively.
Example:
bun ~/.pi/agent/skills/tmux/lib.ts attach pi-task-python-20250107-123456
# Output: tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t pi-task-python-20250107-123456
Sync Sessions
bun ~/.pi/agent/skills/tmux/lib.ts sync
Synchronizes session status with tmux actual state.
Session Persistence
Session information is stored in ${TMPDIR:-/tmp}/pi-tmux-sessions.json. This allows:
- Cross-session recovery
- State tracking across Agent restarts
- Automatic cleanup of stale sessions
Storage Format:
{
"sessions": {
"pi-task-compile-20250107-123456": {
"id": "pi-task-compile-20250107-123456",
"name": "compile",
"category": "task",
"socket": "/tmp/pi-tmux-sockets/pi.sock",
"target": "pi-task-compile-20250107-123456:0.0",
"command": "make clean && make all",
"status": "running",
"createdAt": "2025-01-07T12:34:56Z",
"lastActivityAt": "2025-01-07T12:35:00Z"
}
},
"lastSync": "2025-01-07T12:35:00Z"
}
Use Cases
Sub-task Execution
Execute temporary tasks that require monitoring:
# Start compilation
bun ~/.pi/agent/skills/tmux/lib.ts create compile "make all" task
# Wait for completion (in script)
bun ~/.pi/agent/skills/tmux/lib.ts capture pi-task-compile-20250107-123456 | grep "Build successful"
# Get result
bun ~/.pi/agent/skills/tmux/lib.ts capture pi-task-compile-20250107-123456
# Cleanup
bun ~/.pi/agent/skills/tmux/lib.ts kill pi-task-compile-20250107-123456
Long-running Tasks
Run tasks in the background and check progress later:
# Start training
bun ~/.pi/agent/skills/tmux/lib.ts create training "python train.py --epochs 100" task
# Check progress later
bun ~/.pi/agent/skills/tmux/lib.ts list
bun ~/.pi/agent/skills/tmux/lib.ts capture pi-task-training-20250107-123456
Service Management
Start development servers or services:
# Start dev server
bun ~/.pi/agent/skills/tmux/lib.ts create dev-server "npm run dev" service
# Monitor logs
tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t pi-service-dev-server-20250107-123456
# Stop when done
bun ~/.pi/agent/skills/tmux/lib.ts kill pi-service-dev-server-20250107-123456
Interactive Tools
Use interactive tools like Python REPL, gdb, or 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
# Send commands
bun ~/.pi/agent/skills/tmux/lib.ts send pi-task-python-20250107-123456 "print('Hello')"
bun ~/.pi/agent/skills/tmux/lib.ts send pi-task-python-20250107-123456 "2 + 2"
Status Detection
Sessions have three possible states:
- running: Process is active with recent output
- idle: Process exists but no recent output
- exited: Process has terminated
Status is automatically synced with tmux actual state.
Automatic Cleanup
By default, sessions inactive for more than 24 hours are automatically cleaned up. You can:
-
Trigger manual cleanup:
bun ~/.pi/agent/skills/tmux/lib.ts cleanup [hours] -
Disable auto-cleanup in code:
const tmux = new TmuxManager({ autoCleanup: false });
Helper Scripts
wait-for-text.sh
Polls a pane for a regex pattern with timeout.
./scripts/wait-for-text.sh -t session:0.0 -p 'pattern' [-F] [-T 20] [-i 0.5] [-l 2000]
-t/--target: Pane target (required)-p/--pattern: Regex to match (required); add-Ffor fixed string-T: Timeout in seconds (default: 15)-i: Poll interval in seconds (default: 0.5)-l: History lines to search (default: 1000)
find-sessions.sh
Lists tmux sessions with metadata.
./scripts/find-sessions.sh -S "$SOCKET"
./scripts/find-sessions.sh --all # Scan all sockets
Examples
See the examples/ directory for complete examples:
python-repl.ts: Interactive Python REPLlong-task.ts: Long-running task with progressstart-service.ts: Service management
TypeScript API
You can also use the TypeScript API directly:
import { TmuxManager } from "~/.pi/agent/skills/tmux/lib.ts";
const tmux = new TmuxManager();
// Create session
const session = await tmux.createSession('compile', 'make all', 'task');
// Wait for output
const success = await tmux.waitForText(session.target, 'Build successful', { timeout: 60 });
// Capture output
const output = await tmux.capturePane(session.target, 200);
// Cleanup
await tmux.killSession(session.id);
Monitoring Sessions
After creating a session, ALWAYS tell the user how to monitor it:
To monitor this session yourself:
tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t pi-task-compile-20250107-123456
Or to capture the output once:
tmux -S /tmp/pi-tmux-sockets/pi.sock capture-pane -p -J -t pi-task-compile-20250107-123456:0.0 -S -200
This must be printed immediately after session creation and at the end of the tool loop.
Security Considerations
- Uses private socket path to avoid conflicts
- Sends keys in literal mode (
-l) to prevent shell injection - Checks tmux actual state before cleanup
- Requires explicit confirmation for destructive operations
Troubleshooting
Session not found
Run sync to update session state:
bun ~/.pi/agent/skills/tmux/lib.ts sync
Cannot attach to session
Ensure tmux is installed and the socket path is correct:
tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t <session-id>
Sessions not cleaning up
Manually trigger cleanup:
bun ~/.pi/agent/skills/tmux/lib.ts cleanup
Permission denied on socket
Check socket directory permissions:
ls -la /tmp/pi-tmux-sockets/
Requirements
- tmux (Linux/macOS)
- Bun runtime
- Bash (for helper scripts)
04 同仓库更多 Skills
serpmaven
Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.
revnu-landing-page-audit
Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: "audit my landing page", "why isn't this page converting", "review my homepage", "my ads get clicks but no signups", "people bounce from the pricing page", "CRO review", "improve conversion rate", "is my hero section clear", "roast my landing page", "rewrite my headline", "what's wrong with this page", "landing page feedback", "make the signup page convert better". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.
revnu-growth-context
Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents/revnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says "set up our marketing context", "who is our ideal customer", "write our ICP", "describe the product for marketing", "positioning doc", "what's our brand voice", "remember this about our customers", "log what we tried", "what have we learned from marketing", "we changed pricing, update the context", "update our growth notes", "summarize the business for the agent", "import my product-marketing.md", "start a growth doc", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.
revnu-get-listed
Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: "best X" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says "get us listed", "which directories should we submit to", "how do we get into best-of lists", "why does ChatGPT recommend competitors and not us", "get mentioned in AI answers", "submit to awesome lists", "get on G2", "where are our competitors listed", "pitch listicle authors", "find backlink opportunities", "launch directories", "get into roundups", "Product Hunt alternatives", "where should we be listed", "get cited by Perplexity". Never submits, pays or posts without a yes. Works without a Revnu account.
revnu-ai-readiness-audit
Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks "is my site ready for AI search", "audit my site for AI answers", "AEO audit", "GEO audit", "why doesn't ChatGPT quote our pricing", "make our pages citable by AI", "do I need llms.txt", "does schema help with ChatGPT", "check our structured data", "is our content visible without JavaScript", "AI SEO audit", "optimize our homepage for AI answers", "LLM SEO check", "why does AI get our product wrong", "fix our site for AI Overviews". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.
proxy-troubleshooting
Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.