Skip to content

arjan/ttf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turbo Terminal Filter (TTF)

A high-performance PTY passthrough tool written in Go with live, toggleable output filtering.

Features

  • PTY Passthrough: Spawns a child process attached to a pseudo-terminal
  • Interactive-Only: Designed for real terminal sessions, not piped input
  • Interactive Shell Support: Default interactive shell with proper character echoing
  • Live Filtering: Real-time filtering of output using regex patterns
  • Minimal Interface: Simple, clean overlay without distracting UI elements
  • Interactive Controls:
    • Press Ctrl+S to enter filter mode with simple prompt
    • Press Ctrl+R to clear the filter and show all output
  • Terminal Mode Management: Automatically handles raw terminal mode and restoration
  • Signal Handling: Properly forwards signals to child processes
  • Cross-platform Compatibility: Works on Unix-like systems

Installation

# Clone the repository
git clone <repository-url>
cd ttf

# Install dependencies
go mod tidy

# Build the project
go build -o ttf .

# Install globally (optional)
go install .

Usage

Note: This is an interactive terminal program that must be run in a real terminal session, not with piped input.

Basic Usage

# Start with default interactive shell (/bin/sh -i)
./ttf

# Start with specific command
./ttf -- /bin/bash

# Start with Python interactive mode
./ttf -- /usr/bin/python3 -i

# Start with custom command and arguments
./ttf -- ls -la

Interactive Filtering

  1. Enter Filter Mode: Press Ctrl+S
  2. Type Pattern: Enter a regex pattern (e.g., error|warning)
  3. Apply Filter: Press Enter to enable filtering
  4. Clear Filter: Press Ctrl+R to show all output again

Examples

# Monitor log files with live filtering
./ttf -- tail -f /var/log/system.log

# Interactive Python session with filtered output
./ttf -- python3 -c "
import time
for i in range(10):
    print(f'Line {i}: info message')
    if i % 2 == 0:
        print(f'Line {i}: error message')
    time.sleep(1)
"

# Filter specific commands
./ttf -- find / -name "*.log" 2>/dev/null

Dependencies

  • github.com/creack/pty - PTY handling
  • golang.org/x/term - Terminal mode management

Development

# Run tests
go test ./...

# Format code
go fmt ./...

# Build
go build -o ttf .

# Clean
go clean

How It Works

  1. Process Spawning: Creates a child process attached to a pseudo-terminal
  2. Input Forwarding: Forwards keyboard input to the child process
  3. Output Filtering: Reads child output line by line and applies regex filtering
  4. Interactive Controls: Intercepts Ctrl+S and Ctrl+R for filter management
  5. Terminal Management: Handles raw terminal mode and proper cleanup

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors