Skip to content

Termitty/termitty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Termitty 🐜

A powerful, Selenium-inspired Python framework for terminal and SSH automation.

Python Version License: MIT Code style: black

What is Termitty?

Termitty brings the elegance and simplicity of Selenium WebDriver to the world of terminal automation. Just as Selenium revolutionized web browser automation, Termitty transforms how developers interact with command-line interfaces programmatically.

πŸ†š Quick Comparison

Feature Termitty Fabric Paramiko Pexpect Ansible
Selenium-like API βœ… ❌ ❌ ❌ ❌
Terminal Emulation βœ… Full ❌ ❌ ⚠️ Basic ❌
Session Recording βœ… ❌ ❌ ❌ ❌
AI-Ready βœ… ❌ ❌ ❌ ❌
Interactive Shell βœ… ⚠️ ⚠️ βœ… ❌

β†’ See detailed comparison for more information

✨ Key Features

🎯 Intuitive Selenium-like API

# Familiar patterns for developers who've used Selenium
session = TermittySession()
session.connect('server.com', username='user', key_file='~/.ssh/id_rsa')
session.wait_until(OutputContains('Ready'))

πŸ–₯️ Advanced Terminal Emulation

  • Full ANSI escape code support
  • Virtual terminal with screen buffer management
  • Real-time terminal state tracking
  • Menu and UI element detection

⏱️ Smart Waiting & Pattern Matching

# Wait for specific conditions
session.wait_until(OutputContains('Task completed'), timeout=30)
session.wait_until(PromptReady('$ '))
session.wait_until(OutputMatches(r'Status: \d+%'))

πŸ”„ Interactive Shell Sessions

# Handle interactive applications with ease
with session.interactive_shell() as shell:
    shell.send_line('vim config.txt')
    shell.wait_for_text('INSERT')
    shell.send_keys('Hello World')
    shell.send_key(Keys.ESCAPE)
    shell.send_line(':wq')

πŸ“Ή Session Recording & Playback

# Record your terminal sessions
session.start_recording('demo.json')
# ... perform actions ...
recording = session.stop_recording()

# Playback later
from termitty.recording import SessionPlayer
player = SessionPlayer('demo.json')
player.play(speed=2.0)

⚑ Parallel Execution

# Execute commands across multiple servers
hosts = ['server1.com', 'server2.com', 'server3.com']
pool = ConnectionPool(hosts, username='user', key_file='~/.ssh/id_rsa')

results = pool.execute_on_all('apt update && apt upgrade -y', 
                              strategy='rolling',
                              batch_size=2)

🎨 Terminal UI Navigation

# Navigate terminal UIs programmatically
menu_items = session.terminal.find_menu_items()
session.terminal.click_menu_item('Settings')

πŸ“¦ Installation

# Core package (automation, recording, terminal emulation)
pip install termitty

# With UI support (includes beautiful terminal player)
pip install termitty[ui]

Installation Options:

  • termitty - Core functionality only (lightweight)
  • termitty[ui] - Includes rich terminal player with professional UI

🎬 NEW in v0.1.1: World-Class Recording Player

Experience terminal recordings like never before:

# Record a session
from termitty import TermittySession

with TermittySession() as session:
    session.connect('server.com', username='user', password='pass')
    session.start_recording('demo.json')
    session.execute('echo "Hello World!"')
    session.execute('date')
    session.stop_recording()
# Install with UI support and play back with the beautiful player
pip install termitty[ui]
python docs/terminal_player_ui.py demo.json --speed 1.0

Player Features:

  • 🎨 Professional multi-panel interface
  • πŸ“Š Real-time auto-scrolling terminal
  • ⚑ Variable speeds (0.25Γ— to 4Γ—)
  • 🌈 Smart syntax highlighting
  • 🏷️ Marker navigation
  • ⌨️ Animated typing effects

πŸš€ Quick Start

Basic Command Execution

from termitty import TermittySession

# Connect to a server
session = TermittySession()
session.connect('example.com', username='user', password='pass')

# Execute commands
result = session.execute('ls -la')
print(result.output)

# Use context managers for directory changes
with session.cd('/var/log'):
    logs = session.execute('tail -n 20 syslog')
    print(logs.output)

Interactive Application Handling

# Handle password prompts
session.execute('sudo apt update')
session.wait_until(OutputContains('[sudo] password'))
session.send_line('password', secure=True)

# Navigate interactive installers
session.execute('./install.sh')
session.wait_until(OutputContains('Do you accept? [y/N]'))
session.send_line('y')

Terminal Emulation

# Access the virtual terminal through session state
terminal = session.state.terminal

# Get screen content
screen_text = terminal.get_screen_text()
print(screen_text)

# Find text on screen
if terminal.find_text('Error'):
    print("Error found at:", terminal.cursor_position)

# Take snapshots
snapshot = terminal.snapshot()

πŸ“š Documentation

For comprehensive documentation, visit our docs folder or check out these guides:

πŸ—οΈ Architecture

Termitty is built with a modular architecture:

  • Session Layer: High-level API for SSH connections and command execution
  • Terminal Emulator: Full VT100/ANSI terminal emulation
  • Interactive Shell: Real-time interaction with persistent shell sessions
  • Recording System: Capture and replay terminal sessions
  • Parallel Executor: Efficient multi-host command execution

See our Architecture Documentation for detailed information.

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

Termitty is licensed under the MIT License. See LICENSE for details.

πŸ›£οΈ Roadmap

  • Async/await support for all operations
  • File transfer capabilities (SCP/SFTP)
  • Built-in task templates for common operations
  • Terminal session sharing and collaboration
  • Web-based session viewer
  • Plugin system for custom extensions

πŸ’‘ Use Cases

  • DevOps Automation: Automate server provisioning and configuration
  • Testing: Create robust tests for CLI applications
  • Monitoring: Build intelligent monitoring scripts that react to terminal output
  • Documentation: Record terminal sessions for tutorials and documentation
  • Deployment: Orchestrate complex multi-server deployments
  • AI Agents: Enable LLMs and coding assistants to control terminals β†’ Learn more

πŸ™ Acknowledgments

This project is inspired by the elegance of Selenium WebDriver and the need for better terminal automation tools in the DevOps/SRE space.


Ready to automate your terminal workflows? Check out our examples to get started!

About

The terminal automation framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published