スキル一覧に戻る
erwinkn

tmux-tui

by erwinkn

Cross-platform AI tool configuration (Claude Code, etc.)

0🍴 0📅 2026年1月20日
GitHubで見るManusで実行

SKILL.md


name: tmux-tui description: Interact with TUI applications via tmux. Consider using tuistory skill instead for better synchronization (waitForText vs sleep). Use tmux-tui when you need visual debugging via tmux attach, or when Bun is unavailable. allowed-tools: Bash

tmux TUI Interaction

Control and test interactive terminal applications by running them in tmux sessions, sending keystrokes, and capturing output for verification.

Note: For most TUI automation, prefer the tuistory skill which has proper waitForText synchronization instead of sleep hacks. Use tmux-tui when you need to visually attach to the session for debugging (tmux attach -t name) or when Bun is not available.

Prerequisites

  • tmux must be installed (brew install tmux on macOS)
  • The TUI application must be runnable from command line

Core Commands

CommandPurpose
tmux new-session -d -s NAMECreate detached session
tmux send-keys -t NAME "text" EnterSend keystrokes
tmux capture-pane -t NAME -pGet current screen content
tmux capture-pane -t NAME -p -eGet content with ANSI colors
tmux kill-session -t NAMEClean up session
tmux list-sessionsList active sessions

Workflow

1. Start TUI in Detached Session

# Create session and run command inside it
tmux new-session -d -s tui-test
tmux send-keys -t tui-test "your-cli-command" Enter

# Wait for startup
sleep 2

2. Capture Current State

OUTPUT=$(tmux capture-pane -t tui-test -p)
echo "$OUTPUT"

3. Send Input

# Send single key
tmux send-keys -t tui-test "1"

# Send key + Enter
tmux send-keys -t tui-test "1" Enter

# Send special keys
tmux send-keys -t tui-test Enter      # Enter key
tmux send-keys -t tui-test Escape     # Escape key
tmux send-keys -t tui-test Tab        # Tab key
tmux send-keys -t tui-test Up Down    # Arrow keys
tmux send-keys -t tui-test C-c        # Ctrl+C
tmux send-keys -t tui-test C-m        # Same as Enter

# Send text followed by Enter
tmux send-keys -t tui-test "hello world" Enter

4. Wait and Capture Again

sleep 0.5  # Allow time for TUI to update
OUTPUT=$(tmux capture-pane -t tui-test -p)

5. Assert on Output

# Check for expected text
if echo "$OUTPUT" | grep -q "expected text"; then
    echo "PASS"
else
    echo "FAIL"
fi

# Multiple assertions
echo "$OUTPUT" | grep -q "Menu loaded" && echo "✓ Menu"
echo "$OUTPUT" | grep -q "Option selected" && echo "✓ Selection"

6. Clean Up

tmux kill-session -t tui-test

Complete Example

#!/bin/bash
SESSION="cli-test-$$"

# Start CLI
tmux new-session -d -s "$SESSION"
tmux send-keys -t "$SESSION" "uv run my-cli-app" Enter
sleep 2

# Verify startup
OUTPUT=$(tmux capture-pane -t "$SESSION" -p)
if ! echo "$OUTPUT" | grep -q "Main Menu"; then
    echo "FAIL: CLI didn't start"
    tmux kill-session -t "$SESSION"
    exit 1
fi

# Navigate menu
tmux send-keys -t "$SESSION" "1" Enter
sleep 0.5

# Check result
OUTPUT=$(tmux capture-pane -t "$SESSION" -p)
echo "$OUTPUT" | grep -q "Success" && echo "✓ PASS"

# Quit and cleanup
tmux send-keys -t "$SESSION" "q" Enter
sleep 0.3
tmux kill-session -t "$SESSION"

Special Keys Reference

Keytmux syntax
EnterEnter or C-m
EscapeEscape
TabTab
BackspaceBSpace
Arrow keysUp, Down, Left, Right
Ctrl+CC-c
Ctrl+DC-d
Page Up/DownPPage, NPage
Home/EndHome, End
Function keysF1 through F12

Tips

  • Use unique session names: Include $$ (PID) to avoid conflicts: SESSION="test-$$"
  • Always clean up: Use tmux kill-session even on test failure
  • Adjust sleep times: Complex TUIs may need longer waits (1-2s)
  • Capture scrollback: Use tmux capture-pane -S - for full history
  • Debug visually: Attach to session with tmux attach -t NAME to see what's happening

Error Handling

ErrorCauseFix
can't find sessionSession ended or never startedCheck if command crashed
no server runningtmux server not startedFirst new-session starts it
Empty captureTUI hasn't rendered yetIncrease sleep time
Wrong outputTiming issueAdd sleep after send-keys

スコア

総合スコア

40/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です