🌍 Global Mirror — Visit original CN site →
Back to skills

Tmux

ASecurity

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.

3 stars
0 votes
0 copies
3 views
Added 2/11/2026
developmentpythonbashfrontendbackend

Works with

terminal

Security Analysis

A100/100

Scanned 2/12/2026

Install via CLI

$openskills install knoopx/pi
Download Zip
SKILL.md
---
name: tmux
description: 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.
---

# 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

```bash
# 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

```bash
# 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

```bash
# 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

```bash
# 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

```bash
# 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

```bash
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

```bash
tmux new-session -d -s job 'command'
sleep 0.5
output=$(tmux capture-pane -t job -p)
echo "$output"
```

### Conditional Session

```bash
tmux has -t myserver || tmux new-session -d -s myserver 'command'
```

### Cleanup

```bash
tmux kill-session -t backend
tmux kill-session -t frontend
tmux kill-server  # Kill all
```

## Tips

- Use `tmux new-session -d` for background processes
- Use `tmux capture-pane -p -S -` for full scrollback
- Use `tmux has -t name` to check session existence
- Use `tmux kill-server` to clean up all sessions
- Use `-c /path` to set working directory
- Use `exec bash` to keep session alive after command

Comments (0)

No comments yet. Be the first to comment!

Tmux (Grade A) - Claude Skill | Skills Directory

Stay up to date

Get the latest news on AI tools and skills delivered to your inbox.