obra avatar

Using Tmux For Interactive Commands

This handles the annoying problem of running interactive CLI tools like vim, Python REPLs, or git rebase through Claude. Standard bash can't control these because they need a real terminal, so this uses tmux's detached sessions with send-keys and capture-pane to programmatically drive them. You spin up a session, send input as tmux key names (Enter, Escape, C-c), capture the screen state, repeat as needed. The pattern works well once you remember to sleep briefly after starting a session and always send Enter as a separate argument. Makes it possible to automate things that genuinely need terminal interaction without building your own PTY management.

skills.sh installs
510
GitHub stars
438
last updated
Aug 21, 2026

Install

$ npx -y skills add obra/superpowers-lab --skill using-tmux-for-interactive-commands --agent claude-code

Installs into .claude/skills of the current project.

Files

Using tmux for Interactive Commands

Overview

Interactive CLI tools (vim, interactive git rebase, REPLs, etc.) cannot be controlled through standard bash because they require a real terminal. tmux provides detached sessions that can be controlled programmatically via send-keys and capture-pane.

When to Use

Use tmux when:

  • Running vim, nano, or other text editors programmatically
  • Controlling interactive REPLs (Python, Node, etc.)
  • Handling interactive git commands (git rebase -i, git add -p)
  • Working with full-screen terminal apps (htop, etc.)
  • Commands that require terminal control codes or readline

Don't use for:

  • Simple non-interactive commands (use regular Bash tool)
  • Commands that accept input via stdin redirection
  • One-shot commands that don't need interaction

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
Stop sessiontmux kill-session -t <name>
List sessionstmux list-sessions

Core Pattern

Sponsors

Details

Repository
github.com/obra/superpowers-lab
Categories
Git & Pull Requests, Python, CLI & Terminal
First seen
Jun 3, 2026

More from obra/superpowers-lab

All 4
1spatie avatarspatie-version-controlspatie/guidelines-skillsApply Spatie's version control conventions when creating commits, branches, pull requests, or managing Git repositories; use for naming repos, writing commit me510skills.sh installs
2aj-geddes avatarcicd-pipeline-setupaj-geddes/useful-ai-promptsDesign and implement CI/CD pipelines with GitHub Actions, GitLab CI, Jenkins, or CircleCI. Use for automated testing, building, and deployment workflows.503skills.sh installs
3webmaxru avataragent-skill-deploywebmaxru/enonic-agent-skillsDeploys agent skill collections from any GitHub repository with a /skills folder to one or more distribution surfaces: GitHub releases, Claude Code marketplace,485skills.sh installs
4webmaxru avataragent-skill-deploywebmaxru/ai-native-devDeploys agent skill collections from any GitHub repository with a /skills folder to one or more distribution surfaces: GitHub releases, Claude Code marketplace,484skills.sh installs
5parcadei avatarreleaseparcadei/continuous-claude-v3Release preparation workflow - security audit → E2E tests → review → changelog → docs483skills.sh installs
6josiahsiegel avatarbash-masterjosiahsiegel/claude-plugin-marketplaceExpert bash/shell scripting across environments where Bash is available (Linux, macOS, Git Bash on Windows, WSL, containers). This is a Bash-focused skill - it 462skills.sh installs