How to Record a Terminal GIF

Step-by-step guide to recording terminal sessions as GIF animations using VHS, asciinema, and AgentGIF CLI.

1. Prerequisites

To record terminal GIFs, you need:

VHS works by reading a .tape file that describes keystrokes, commands, and timing — then it replays those actions in a virtual terminal and captures the output as a GIF.

2. Install VHS

PlatformInstall Command
macOSbrew install vhs
Ubuntu/Debiansudo mkdir -p /etc/apt/keyrings && curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg && echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list && sudo apt update && sudo apt install vhs
Arch Linuxyay -S vhs
Gogo install github.com/charmbracelet/vhs@latest

Verify the installation:

vhs --version

3. Create a Tape File

A tape file is a plain-text script that tells VHS what to type, when to wait, and what settings to use. Create a file called demo.tape:

Output demo.gif
Set Shell "bash"
Set FontSize 16
Set Width 1000
Set Height 580
Set Theme "Catppuccin Mocha"

Type "echo 'Hello, world!'"
Enter
Sleep 2s

Type "ls -la"
Enter
Sleep 3s

Core Commands

CommandDescriptionExample
OutputSet the output file pathOutput "demo.gif"
TypeType text (simulates keystrokes)Type "git status"
EnterPress EnterEnter
SleepWait for a durationSleep 2s
Ctrl+CSend keyboard shortcutCtrl+C
HideStop recording (for setup)Hide
ShowResume recordingShow

4. Configure Settings

Put Set commands at the top of your tape file, before any Type commands.

Recommended Settings for AgentGIF

Set Shell "zsh"
Set FontSize 15
Set Width 1000
Set Height 580
Set Padding 20
Set Theme "Catppuccin Mocha"
Set TypingSpeed 50ms
Set CursorBlink false

All Available Settings

SettingDefaultDescription
Shell"bash"Shell to use (bash, zsh, fish, sh)
FontSize14Font size in pixels
Width800Terminal width in pixels
Height600Terminal height in pixels
Padding0Padding around terminal
Theme"default"Color theme (see theme gallery)
TypingSpeed50msDelay between keystrokes
Framerate50GIF frames per second
PlaybackSpeed1Playback speed multiplier
CursorBlinktrueShow blinking cursor
LetterSpacing0Extra letter spacing
LineHeight1.0Line height multiplier

Themes

VHS ships with 44 built-in themes. Popular choices for developer documentation:

ThemeStyle
Catppuccin MochaWarm dark (pastel accents)
DraculaDark purple
Tokyo NightBlue-tinted dark
NordArctic blue
One DarkAtom-inspired dark
Solarized DarkClassic dark with warm tones
MonokaiSublime Text-inspired

Browse all themes with live previews: Theme Gallery.

5. Record the GIF

vhs demo.tape

VHS opens a headless browser, replays the tape, and saves the GIF. Typical recording takes 10-30 seconds.

Preview before uploading:

# macOS
open demo.gif

# Linux
xdg-open demo.gif

6. Optimize File Size

AgentGIF accepts GIFs up to 10 MB, but smaller files load faster. Tips for keeping GIF size down:

TechniqueImpact
Reduce dimensions (Width 800)Significant — halving width quarters the file size
Lower framerate (Framerate 30)Moderate — reduces frames by 40%
Shorter recordingSignificant — aim for 5-15 seconds
Use PlaybackSpeed 1.5Moderate — fewer total frames
Disable cursor blink (CursorBlink false)Small — fewer unique frames
Solid background (avoid transparency)Small — better GIF compression

For the best balance of quality and size, the recommended settings above produce GIFs around 100-300 KB for a 10-second recording.

7. Upload to AgentGIF

Upload via CLI (fastest):

agentgif upload demo.gif \
  --title "Git Interactive Rebase" \
  --command "git rebase -i HEAD~3" \
  --tags git,rebase \
  --open

Or upload via the web interface — drag and drop the GIF file.

Including a cast file enables the AI agent layer:

agentgif upload demo.gif --cast demo.cast --title "My Demo"

8. Advanced Tape Features

Hide/Show for Setup

Use Hide/Show to run setup commands without recording them:

Hide
Type "cd /tmp/demo-project"
Enter
Type "mkdir -p src"
Enter
Show

# Now recording starts
Type "ls -la"
Enter
Sleep 2s

Multiple Output Formats

VHS can output multiple formats simultaneously:

Output demo.gif
Output demo.mp4
Output demo.webm

Environment Variables

Set Shell "bash"
Type "export PS1='$ '"
Enter
Hide
Sleep 500ms
Show

Keyboard Shortcuts

Ctrl+C     # Cancel current command
Ctrl+L     # Clear screen
Ctrl+D     # EOF / exit
Tab        # Tab completion
Up         # Previous command
Escape     # Escape key

9. Alternative Recording Tools

ToolOutputProsCons
VHSGIF, MP4, WebMScripted, reproducible, themesRequires setup
asciinema.castLive recording, small filesNo GIF output (needs conversion)
TerminalizerGIFLive recording, YAML configLarge file sizes
PeekGIF, WebMGUI screen recorderNot terminal-specific

We recommend VHS for scripted demos (reproducible, version-controllable) and asciinema + VHS conversion for live recordings.

See also: asciinema vs AgentGIF comparison.