Main Site ↗

using-tmux

by benchflow-ai897172GitHub

Control interactive CLI tools that require a real terminal via tmux send-keys. Use for git rebase -i, git add -p, vim, nano, Python/Node REPLs, or any command that hangs waiting for terminal input.

Unlock Deep Analysis

Use AI to visualize the workflow and generate a realistic output preview for this skill.

Powered by Fastest LLM

Development
Compatible Agents
Claude Code
Claude Code
~/.claude/skills/
Codex CLI
Codex CLI
~/.codex/skills/
Gemini CLI
Gemini CLI
~/.gemini/skills/
O
OpenCode
~/.opencode/skills/
O
OpenClaw
~/.openclaw/skills/
GitHub Copilot
GitHub Copilot
~/.copilot/skills/
Cursor
Cursor
~/.cursor/skills/
W
Windsurf
~/.codeium/windsurf/skills/
C
Cline
~/.cline/skills/
R
Roo Code
~/.roo/skills/
K
Kiro
~/.kiro/skills/
J
Junie
~/.junie/skills/
A
Augment Code
~/.augment/skills/
W
Warp
~/.warp/skills/
G
Goose
~/.config/goose/skills/
SKILL.md

Using tmux for Interactive Commands

Persona: Terminal automation expert - enables programmatic control of interactive applications.

When NOT to Use

  • Simple non-interactive commands (use Bash directly)
  • Commands that accept stdin redirection
  • One-shot commands that exit immediately

Quick Reference

TaskCommand
Start sessiontmux new-session -d -s NAME COMMAND
Send inputtmux send-keys -t NAME 'text' Enter
Capture outputtmux capture-pane -t NAME -p
Kill sessiontmux kill-session -t NAME
List sessionstmux list-sessions

Core Pattern

# 1. Create detached session
tmux new-session -d -s mysession vim file.txt

# 2. Wait for init
sleep 0.3

# 3. Send keys (Enter, Escape are tmux key names, not \n)
tmux send-keys -t mysession 'iHello World' Escape ':wq' Enter

# 4. Capture output
tmux capture-pane -t mysession -p

# 5. Clean up
tmux kill-session -t mysession

Special Keys

Keytmux Name
ReturnEnter
EscapeEscape
Ctrl+CC-c
Ctrl+XC-x
ArrowsUp, Down, Left, Right
SpaceSpace
BackspaceBSpace

Common Patterns

Interactive Git Rebase

tmux new-session -d -s rebase -c /path/to/repo git rebase -i HEAD~3
sleep 0.5
tmux capture-pane -t rebase -p  # See editor
tmux send-keys -t rebase 'cwsquash' Escape 'j' 'cwsquash' Escape ':wq' Enter
tmux capture-pane -t rebase -p  # See result
tmux kill-session -t rebase

Git Add Patch Mode

tmux new-session -d -s patch -c /path/to/repo git add -p
sleep 0.3
tmux capture-pane -t patch -p  # See hunk
tmux send-keys -t patch 'y'    # Stage this hunk
tmux capture-pane -t patch -p  # See next
tmux send-keys -t patch 'n'    # Skip this one
tmux send-keys -t patch 'q'    # Quit
tmux kill-session -t patch

Python REPL

tmux new-session -d -s py python3
sleep 0.2
tmux send-keys -t py 'import math' Enter
tmux send-keys -t py 'print(math.pi)' Enter
tmux capture-pane -t py -p
tmux send-keys -t py 'exit()' Enter
tmux kill-session -t py

Vim Edit

tmux new-session -d -s vim vim /tmp/test.txt
sleep 0.3
tmux send-keys -t vim 'i' 'New content here' Escape ':wq' Enter
tmux kill-session -t vim 2>/dev/null

Common Mistakes

MistakeFix
Blank output after new-sessionAdd sleep 0.3 before capture
Commands typed but not executedSend Enter as separate argument
Using \n for newlineUse Enter (tmux key name)
Orphaned sessionsAlways kill-session when done

Should NOT Attempt

  • Using for non-interactive commands (wasteful overhead)
  • Sending shell escape sequences (\n, \t) instead of tmux key names
  • Forgetting cleanup (orphaned sessions accumulate)
  • Capturing immediately without sleep (blank output)

Failure Behavior

If tmux commands fail:

  1. Check if tmux is installed: which tmux
  2. Check if session exists: tmux has-session -t NAME
  3. List all sessions: tmux list-sessions
  4. Kill stuck session: tmux kill-session -t NAME

Escalation

SituationAction
tmux not installedAsk user to install: apt install tmux
Complex multi-step interactionBreak into smaller send-keys + capture cycles
Need to see full scrollbackUse tmux capture-pane -t NAME -p -S -1000

Related Skills

  • multi-llm: Uses tmux for LLM CLI delegation
  • git-workflow: Interactive git commands (rebase -i, add -p)

Source: https://github.com/benchflow-ai/SkillsBench#registry-terminal_bench_2.0-full_batch_reviewed-terminal_bench_2_0_large-scale-text-editing-environment-skills-using-tmux

Content curated from original sources, copyright belongs to authors

Grade B
-AI Score
Best Practices
Checking...
Try this Skill

User Rating

USER RATING

0UP
0DOWN
Loading files...

WORKS WITH

Claude Code
Claude
Codex CLI
Codex
Gemini CLI
Gemini
O
OpenCode
O
OpenClaw
GitHub Copilot
Copilot
Cursor
Cursor
W
Windsurf
C
Cline
R
Roo
K
Kiro
J
Junie
A
Augment
W
Warp
G
Goose