A terminal session recorder and replayer written in C that allows you to capture and replay terminal sessions with precise timing.
This is a hobby project created for fun and learning purposes. It's still in active development and may contain bugs or incomplete features. If you encounter any issues, please report them in the Issues section. Contributions are welcome and encouraged!
- Record terminal sessions: Capture all terminal input/output with accurate timing information
- Replay sessions: Play back recorded sessions with original timing
- Session analysis: Analyze recorded sessions with detailed statistics and insights
- JSON format: Sessions are stored in a structured JSON format for easy parsing
- Signal handling: Graceful shutdown and file closure on interruption
- Lightweight: Minimal dependencies, written in pure C
- Web browser player: Advanced browser-based player available at https://github.com/rewindtty/browser_player
rewindtty now supports an interactive mode that provides a script-like experience similar to script
and scriptreplay
utilities. This mode allows you to record and replay terminal sessions in real-time with enhanced interactivity.
Note: This feature is currently experimental and may have limitations or bugs.
Feature | Interactive Mode | Legacy Mode |
---|---|---|
Recording Style | Real-time shell interaction | Command-by-command capture |
Replay Experience | Live terminal emulation (like scriptreplay) | Step-by-step command replay |
Session Analysis | ❌ Not available* | ✅ Full analysis with statistics |
File Format | Enhanced JSON with timing data | Standard JSON format |
Browser Player | ✅ Compatible | ✅ Compatible |
Performance | Higher memory usage | Lightweight |
Use Case | Full session recording/replay | Command analysis and optimization |
*The analyze tool is not available in interactive mode because commands cannot be reliably stored and parsed from the raw shell interaction data.
- GCC compiler
- GNU Make
- Standard C library with GNU extensions
- Git (for cloning project and submodules)
This project uses cJSON as a Git submodule. Make sure to clone with submodules:
git clone --recurse-submodules https://github.com/debba/rewindtty.git
If you already cloned the repository without submodules, run:
git submodule update --init --recursive
make
This will create the executable at build/rewindtty
.
To clean build artifacts:
make clean
To start recording a terminal session:
./build/rewindtty record [--interactive] [file]
This will create a new session file (defaults to data/session.json
if no file is specified) and begin capturing all terminal activity.
To replay a previously recorded session:
./build/rewindtty replay [file]
This will read the session file (defaults to data/session.json
if no file is specified) and replay it with the original timing.
To analyze a recorded session and get detailed statistics:
./build/rewindtty analyze [file]
This will generate a comprehensive analysis report including:
- Total commands executed and session duration
- Average time per command
- Most frequently used commands
- Slowest commands
- Commands that generated errors or warnings
- Helpful suggestions for optimization
Usage: rewindtty [record|replay|analyze] [file]
Commands:
record [file] Start recording a new terminal session to specified file (default: data/session.json)
replay [file] Replay a recorded session from specified file (default: data/session.json)
analyze [file] Analyze a recorded session and generate statistics report (default: data/session.json)
For an advanced web-based player with enhanced features and a modern interface, visit: https://github.com/rewindtty/browser_player
You can try the player here: https://play.rewindtty.dev
rewindtty/
├── src/
│ ├── main.c # Main program entry point
│ ├── recorder.c # Session recording functionality
│ ├── recorder.h # Recording function declarations
│ ├── replayer.c # Session replay functionality
│ ├── replayer.h # Replay function declarations
│ ├── analyzer.c # Session analysis functionality
│ ├── analyzer.h # Analysis function declarations
│ ├── utils.c # Utility functions
│ └── utils.h # Utility function declarations
├── data/
│ └── session.json # Default session storage file
├── build/ # Build output directory
├── assets/
│ └── demo.gif # Demo animation
├── libs/
│ └── cjson/ # JSON parsing library
├── LICENSE # MIT License
├── Makefile # Build configuration
└── README.md # This file
Sessions are stored in JSON format in the data/session.json
file. The format captures timing information and terminal data to enable accurate replay.
The recorder handles interruption signals (like Ctrl+C) gracefully by:
- Closing the session file properly
- Writing the final JSON structure
- Cleaning up resources before exit
The project uses the following GCC flags:
-Wall -Wextra
: Enable comprehensive warnings-std=gnu99
: Use GNU C99 standard-g
: Include debugging symbols
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Andrea Debernardi
- Uses standard POSIX system calls for terminal interaction
- Implements proper signal handling for clean shutdown
- JSON output format enables integration with other tools
- Minimal memory footprint and dependencies