tmux

Automates interactive CLI and TUI testing through tmux session control and output capture.

Updated Nov 7, 2024
One-click install
npx skills add https://github.com/jeremysball/dotfiles --skill tmux-jeremysball
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tmux
Source: https://github.com/jeremysball/dotfiles/tree/main/.pi/skills-archive/tmux
Command: npx skills add https://github.com/jeremysball/dotfiles --skill tmux-jeremysball

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Interactive command-line programs and terminal UIs cannot be tested or automated with simple shell pipes, and tmux itself fails to start in headless environments like CI or containers. This Skill provides the exact command patterns for driving interactive terminal sessions programmatically and capturing their output. ## Core Features & Use Cases - Session Automation: Start detached tmux sessions, send keystrokes and commands, and capture pane output for assertions. - Headless Environment Fix: Diagnose and resolve the "no server running" error using setsid and script to allocate a pseudo-terminal in CI, containers, and non-interactive shells. - Use Case: You need to verify that a TUI application responds correctly to keyboard input. Start it in a detached tmux session, send keystrokes with send-keys, capture the rendered screen with capture-pane, and assert on the output. ## Quick Start Use the tmux skill to launch my CLI app in a detached session, send it some input, and capture the resulting screen output.

Frequently Asked Questions about tmux

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate an interactive CLI program with tmux?

Start a detached session with tmux new-session -d -s name "cmd", inject input using tmux send-keys -t name "input" Enter, and read results with tmux capture-pane -t name -p. Finish by killing the session with tmux kill-session -t name.

How to capture terminal output from a tmux session?

Use tmux capture-pane -t session-name -p to print the current pane contents to stdout. Add -S -100 to include the last 100 lines of scrollback history for longer outputs.

Why does tmux say no server running in CI or containers?

Tmux requires a controlling terminal (/dev/tty), which is absent in non-interactive environments, causing an ENXIO error and immediate server exit. Wrap the start command in setsid script -q -c "tmux new-session -d ..." /dev/null to allocate a pseudo-terminal.

Can I pipe commands into tmux with echo?

No. Piping echo output into tmux runs the command in a new shell rather than inside the target session. Always use tmux send-keys -t session "cmd" Enter to deliver input to the running session.

When should I not use tmux for automation?

Tmux automation is meant for interactive CLI and TUI programs. For non-interactive commands that simply produce stdout output, run them directly in the shell instead of wrapping them in a terminal multiplexer.