using-tmux-for-interactive-commands

Use when you need to run interactive CLI tools (vim, git rebase -i, Python REPL, etc.) that require real-time input/output - provides tmux-based approach for controlling interactive sessions through detached sessions and send-keys

By obra · 482 installs

npx skills add obra/superpowers-lab --skill using-tmux-for-interactive-commands

Source repository · Upstream listing

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 Task Command Start session tmux new session d s <name <command Send input tmux send keys t <name 'text' Enter Capture output tmux capture pane t <name p Stop session tmux kill session t <name List sessions tmux list sessions Core Pattern Before (Won't Work) After (Works) Implementation Basic Workflow 1. Create detached session with the interactive command 2. Wait briefly for initialization (100 500ms depending on command) 3. Send input using send keys (can send special keys like Enter, Escape) 4. Capture output using capture pane p to see current screen state 5. Repeat steps 3 4 as needed 6. Terminate session when done Special Keys Common tmux key names: Enter Return/newline Escape ESC key C c Ctrl+C C x Ctrl+X Up , Down , Left , Right Arrow keys Space Space bar BSpace Backspace Working Directory Specify working directory when creating session: Helper Wrapper For easier use, see /home/jesse/git/interactive command/tmux wrapper.sh : Common Patterns Python REPL Vim Editing Interactive Git Rebase Common Mistakes Not Waiting After Session Start Problem: Capturing immediately after new session shows blank screen Fix: Add brief sleep (100 500ms) before first capture Forgetting Enter Key Problem: Commands typed but not executed Fix: Explicitly send Enter Using Wrong Key Names Problem: tmux send keys t sess '\n' doesn't work Fix: Use tmux key names: Enter , not \n Not Cleaning Up Sessions Problem: Orphaned tmux sessions accumulate Fix: Always kill sessions when done Real World Impact Enables programmatic control of vim/nano for file editing Allows automation of interactive git workflows (rebase, add p) Makes REPL based testing/debugging possible Unblocks any tool that requires terminal interaction No need to build custom PTY management tmux handles it all