termsnap
v0.5.0
Published
📸 Creates beautiful screenshots, videos, and GIFs based on terminal command output.
Maintainers
Readme
termsnap
Creates beautiful screenshots, videos, and GIFs based on terminal command output. With full local font and emoji support.
npx termsnap "lolcat -f <(figlet -f banner3 termsnap)"Features
This project leverages Go-based terminal output proxy combined with web rendering technology to deliver pixel-perfect terminal screenshots.
- Interactive Terminal Support: Capture interactive terminal sessions through Go-based terminal output proxy
- Local Font & Emoji Support: Perfect rendering of your system fonts and emoji characters
- Customizable Themes: Extensive theme customization through configuration files
- Multiple Output Formats: Export as HTML, images (PNG/JPEG/WebP), animated GIFs, videos (MP4/AVI/MOV/WebM), or browser preview
- Animation: Generate animated HTML or video output with typing effects
Usage Examples
# Browser preview
npx termsnap "command" --animate --open
# Save as HTML file
npx termsnap "command" --html
# Save as screenshot
npx termsnap "command" --png
# Save as video
npx termsnap "command" --mp4 --fps 60
# Save as animated GIF
npx termsnap "command" --gif --gif-fps 20 --gif-scale 720
# Custom theme and decoration
npx termsnap "command" --open --theme "vitesse-light" --decoration
# Save as animated HTML file
npx termsnap "command" --animateOutput Formats
Generate your terminal output in multiple formats:
- HTML: Save as standalone HTML file with embedded styling
- Images: Export as PNG, JPEG, or WebP formats
- Animated GIFs: Export as optimized GIF with customizable frame rate and scale
- Videos: Export as MP4, AVI, MOV, or WebM formats with customizable frame rate
- Browser Preview: Open directly in browser (powered by Broz)
Theme Customization
termsnap supports termsnap.config.ts for persistent configuration and theme customization. You can:
- Use built-in themes (vitesse, catppuccin)
- Use remote themes from iTerm2-Color-Schemes VSCode directory
- Create custom themes in
termsnap.config.ts
Remote Themes
You can use any theme from the iTerm2-Color-Schemes VSCode directory. If the theme name is not in the built-in list, termsnap will automatically attempt to download it from the repository:
# Use a remote theme (e.g., 0x96f)
npx termsnap "command" --theme "0x96f"Animated Command Input
When using the --animate option to generate animated HTML output, you can customize the typing animation behavior through typedOptions configuration:
// termsnap.config.ts
import { defineConfig } from './src/index'
export default defineConfig({
typedOptions: {
speed: 100, // Typing speed in milliseconds per character
initialDelay: 0, // Initial delay before starting to type
pauseAfter: 500 // Pause duration after typing completes
}
})Configuration Options
Server Settings
port- Server port (default: 3000)force- Force to download the theme from remote
Output Options
dpi- Device pixel ratio for screenshotpng- Generate png and save to filejpeg- Generate jpeg and save to filewebp- Generate webp and save to filegif- Generate animated gif and save to filegifFps- Frames per second for gif output (default: 20)gifScale- Scale for gif output (default: 720)fps- Frames per second for video output (default: 60)mp4- Generate mp4 video and save to fileavi- Generate avi video and save to filemov- Generate mov video and save to filewebm- Generate webm video and save to filehtml- Generate HTML template and save to fileanimate- Generate animated HTML template and save to fileloop- Loop the animation for a given number of millisecondsopen- Open browser after generating HTML template
Terminal Styling
theme- Terminal theme (vitesse-dark, vitesse-light, catppuccin variants, etc.)colors- Custom terminal color configurationheight- Terminal heightwidth- Terminal widthdecoration- Draw window decorations (minimize, maximize, close buttons)cmd- Show command in the terminaltyped- Typed command in the terminal
Font Configuration
fontAspectRatio- Terminal font aspect ratio (default: 0.6)fontFamily- Terminal font familyfontSize- Terminal font sizefontWeight- Terminal font weightlineHeight- Terminal line height
Border & Layout
borderRadius- Terminal border radiusborderWidth- Terminal border widthborderColor- Terminal border colorboxShadow- Terminal box shadowpadding- Terminal paddingmargin- Terminal margin
Typed Configuration
speed- Typing speed in milliseconds per characterinitialDelay- Initial delay before starting to typepauseAfter- Pause after typing completes
Cache Management
termsnap caches downloaded binaries and remote themes to improve performance. You can manage the cache using the following command:
# Clean all cached files (binaries and themes)
npx termsnap cache:cleanThis command will remove:
- Downloaded Go binaries used for terminal session capture
- Cached remote themes from iTerm2-Color-Schemes repository
Use this command if you're experiencing issues with cached files or want to free up disk space.
Acknowledgments
This project was inspired by:
- termshot - Creates screenshots based on terminal command output
- freeze - Generate images of code and terminal output 📸
Why termsnap?
I wanted a simple way to create screenshots for my CLI tools to include in README files. However, existing tools had limitations with fonts, emoji support, and interactive terminal sessions. This led me to create termsnap - a terminal screenshot tool that feels like recording your terminal sessions with perfect fidelity.
License
MIT License © jinghaihan
