Skip to content
Go back

Asciinema Terminal Replay

Embed terminal session recordings in your blog posts using the AsciinemaPlayer component.

asciinema is a terminal session recording and playback tool. With the :::asciinema directive, you can embed recorded terminal sessions directly in your blog posts.


Basic Example

Here’s a simple terminal session demo:

Usage

Use the :::asciinema directive in Markdown files:

:::asciinema{src="/casts/demo.cast"}
markdown

Recording .cast Files

Use the asciinema CLI to record terminal sessions:

# Install
brew install asciinema    # macOS
sudo apt install asciinema # Ubuntu

# Record
asciinema rec demo.cast

# Record a specific command
asciinema rec -c "pnpm run build" build-demo.cast

# Set idle time compression
asciinema rec -i 2 demo.cast
bash

Press Ctrl+D or type exit to stop recording. Place the generated .cast file in public/casts/ to reference it.

Auto Play

Set autoPlay to start playback automatically:

Directive Attributes

AttributeTypeDefaultDescription
srcstringrequiredPath to .cast file
colsstring80Terminal columns
rowsstring24Terminal rows
speedstring1Playback speed multiplier
idleTimeLimitstring2Idle time compression threshold (seconds)
fitstring"width"Fit mode
autoPlaystringfalseAuto-start playback
loopstringfalseLoop playback

The player automatically follows the blog’s light/dark theme.



Previous Post
Why astro-minimax: Design Decisions & Technical Philosophy
Next Post
Excalidraw Whiteboard: Hand-Drawn Diagrams in Your Blog

评论区

文明评论,共建和谐社区