Daemon-based tmux pane manager with learning patterns
Project description
termtap
Execute commands in tmux panes with intelligent state detection via pattern learning.
Features
- 🤖 Pattern Learning - Teach termtap process states (ready/busy) interactively
- 🎯 Smart Execution - Commands wait for processes to be ready before sending
- 🖥️ Companion UI - Visual pattern editor and queue management
- 📡 Daemon Architecture - Background process with RPC communication
- 🔌 MCP Support - Tools and resources for Claude/LLMs
- 📦 Terminal Emulation - Precise output capture with tmux streaming
Prerequisites
Required system dependencies:
- tmux - Terminal multiplexer
- gum - Interactive terminal UI components (for pattern editing)
# macOS
brew install tmux gum
# Arch Linux
sudo pacman -S tmux gum
# Ubuntu/Debian
sudo apt install tmux
# For gum: https://github.com/charmbracelet/gum#installation
Installation
# Install via uv tool (recommended)
uv tool install termtap
# Or with pipx
pipx install termtap
# Update to latest
uv tool upgrade termtap
Quick Start
1. Start Daemon
termtap daemon start
2. Launch Companion UI (optional but recommended)
termtap companion
The companion provides:
- Pattern editor with live preview
- Queue viewer for pending actions
- Pane selector for interactive workflows
3. Run REPL
termtap
4. Execute Commands
>>> execute("python3")
# First time: Companion asks if process is ready
# You teach the pattern once, termtap learns it
>>> pane() # View output
MCP Setup for Claude
# Quick setup with Claude CLI
claude mcp add termtap -- termtap --mcp
# Or manually edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"termtap": {
"command": "termtap",
"args": ["--mcp"]
}
}
}
Commands
| Command | Description |
|---|---|
execute(command, target=None) |
Run command in tmux pane, wait for ready state |
pane(target=None, offset=0, limit=100) |
Read pane output with pagination |
ls(filter=None) |
List tmux sessions |
interrupt(target=None) |
Send Ctrl+C to pane |
send_keystrokes(keys, target=None) |
Send raw keystrokes (for interactive programs) |
debug(code) |
Inspect daemon state (Python expressions) |
Pattern Learning Workflow
First Time Execution
>>> execute("python3")
# Companion shows: "Is this process ready? (y/n)"
# You press 'y' and mark the pattern: ">>> "
Pattern Storage
Patterns are saved to ~/.termtap/patterns.json:
{
"python": {
"ready": [">>> ", "\\.\\.\\. "]
}
}
Subsequent Executions
>>> execute("print('hello')")
# Automatically waits for ">>> " pattern
# Executes immediately when ready
Architecture
Components
- Daemon (
termtap daemon) - Background process managing pane state - Client - RPC client in REPL/MCP mode
- Companion (
termtap companion) - Textual UI for pattern management - Terminal Emulator - SlimScreen with pyte for output capture
Action Lifecycle
- SELECTING_PANE - Choose target pane (if not specified)
- READY_CHECK - Check if process matches learned patterns
- WATCHING - Command sent, waiting for completion
- COMPLETED - Process returned to ready state
Pattern Matching
Process Output Pattern State
---------------- -------- -------
>>> _ >>> $ ready
... \.\.\. $ ready
Executing... (any) busy
Development
# Clone repository
git clone https://github.com/angelsen/tap-tools
cd tap-tools/packages/termtap
# Install for development
uv sync
# Run checks
basedpyright # Type checking
ruff check --fix # Linting
# Run development version
uv run termtap
# Stop daemon
termtap daemon stop
Troubleshooting
Daemon not responding
termtap daemon status # Check daemon state
termtap daemon stop # Stop daemon
termtap daemon start # Restart
Pattern not matching
termtap companion # Open companion UI
# Navigate to Patterns → Edit pattern → Test with preview
Stuck in READY_CHECK
- Open companion UI
- Queue tab shows pending actions
- Mark pattern as ready/busy or cancel action
License
MIT - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
termtap-0.12.0.tar.gz
(86.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
termtap-0.12.0-py3-none-any.whl
(89.6 kB
view details)
File details
Details for the file termtap-0.12.0.tar.gz.
File metadata
- Download URL: termtap-0.12.0.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5709a2d0207306b30ab8f4803b9e083c1de86281af6da12d429ce46683b46454
|
|
| MD5 |
e296f0493b2fb617fe9c2ad26e706fa3
|
|
| BLAKE2b-256 |
f2ba1d0457b9be0f48b3eaa7289edfe105b9a504c25ffd9a68d6ecbeaffcbe78
|
File details
Details for the file termtap-0.12.0-py3-none-any.whl.
File metadata
- Download URL: termtap-0.12.0-py3-none-any.whl
- Upload date:
- Size: 89.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4365a15e0747562d07b95d7b77d2b564cb28263aa35d6a6df4859cfe9dfc0a18
|
|
| MD5 |
c2e141f98e273f32523a4565a5ac3114
|
|
| BLAKE2b-256 |
ddc09646bb6503a4f068f6cc7edafb5d40ef2d12ab53064fa66a87cf5193e602
|