Agent skill
tmux
Manages background processes, captures command output, and handles session multiplexing. Use when running long-running commands, capturing output from detached processes, or managing concurrent tasks in headless environments.
Install this agent skill to your Project
npx add-skill https://github.com/knoopx/pi/tree/main/agent/skills/tmux
SKILL.md
tmux
Terminal multiplexer for background processes, output capture, and session management.
Quick Reference
| Command | Description |
|---|---|
tmux new -d -s name 'cmd' |
Run command in background session |
tmux capture-pane -t name -p |
Capture output from session |
tmux send-keys -t name 'text' Enter |
Send input to session |
tmux kill-session -t name |
Terminate session |
tmux ls |
List all sessions |
tmux has -t name |
Check if session exists |
Running Background Processes
# Run command in new detached session
tmux new-session -d -s myserver 'python -m http.server 8080'
# With specific working directory
tmux new-session -d -s build -c /path/to/project 'make build'
# Keep session alive after command completes
tmux new-session -d -s task 'command; exec bash'
# Run only if session doesn't exist
tmux has -t myserver || tmux new-session -d -s myserver 'command'
Capturing Output
# Capture visible output
tmux capture-pane -t mysession -p
# Capture entire scrollback history
tmux capture-pane -t mysession -p -S -
# Capture last N lines
tmux capture-pane -t mysession -p -S -100
# Save to file
tmux capture-pane -t mysession -p > output.txt
# Capture with escape sequences (colors)
tmux capture-pane -t mysession -p -e
Sending Input
# Send text and Enter
tmux send-keys -t mysession 'echo hello' Enter
# Send without Enter
tmux send-keys -t mysession 'some-text'
# Send Ctrl+C
tmux send-keys -t mysession C-c
Session Management
# List sessions
tmux list-sessions
tmux ls
# Kill specific session
tmux kill-session -t myserver
# Kill all sessions
tmux kill-server
# Check if session exists
tmux has -t mysession
Wait for Completion
# Signal completion from command
tmux new-session -d -s job 'command; tmux wait-for -S job-done'
# Wait for signal
tmux wait-for job-done
Common Patterns
Development Servers
tmux new-session -d -s backend 'bun run backend'
tmux new-session -d -s frontend 'bun run frontend'
tmux new-session -d -s tests 'vitest --watch'
Run and Capture Output
tmux new-session -d -s job 'command'
sleep 0.5
output=$(tmux capture-pane -t job -p)
echo "$output"
Conditional Session
tmux has -t myserver || tmux new-session -d -s myserver 'command'
Cleanup
tmux kill-session -t backend
tmux kill-session -t frontend
tmux kill-server # Kill all
Tips
- Use
tmux new-session -dfor background processes - Use
tmux capture-pane -p -S -for full scrollback - Use
tmux has -t nameto check session existence - Use
tmux kill-serverto clean up all sessions - Use
-c /pathto set working directory - Use
exec bashto keep session alive after command
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
conventional-commits
Writes and reviews Conventional Commits commit messages (v1.0.0) to support semantic versioning and automated changelogs. Use when drafting git commit messages, PR titles, release notes, or when enforcing a conventional commit format (type(scope): subject, BREAKING CHANGE, footers, revert).
nix-flakes
Creates reproducible builds, manages flake inputs, defines devShells, and builds packages with flake.nix. Use when initializing Nix projects, locking dependencies, or running nix build/develop commands.
skill-authoring
Writes effective pi skills with proper structure, concise content, and progressive disclosure. Use when creating new skills, improving existing skills, or reviewing skill quality.
gtkx
Build GTK4 desktop applications with GTKX React framework. Use when creating React components that render as native GTK widgets, working with GTK4/Libadwaita UI, handling signals, virtual lists, menus, or building Linux desktop UIs.
nu-shell
Processes structured data through pipelines, filters tables, transforms JSON/CSV/YAML, and defines custom commands. Use when scripting with typed parameters or working with tabular data.
nix
Runs packages temporarily, creates isolated shell environments, and evaluates Nix expressions. Use when executing tools without installing, debugging derivations, or working with nixpkgs.
Didn't find tool you were looking for?