The .cd (Cinema Display) format is a declarative scripting language for creating animated SVG terminal recordings.
A .cd file consists of:
- Output declaration (optional)
- Settings (optional)
- Requirements (optional)
- Commands (required)
# Comments start with #
Output demo.svg
Set Width 800
Set Height 600
Set Theme dracula
Type "echo 'Hello World'"
Enter
Sleep 1s
Specify the output SVG file path.
Output path/to/output.svg
If not specified, defaults to <input-filename>.svg or the -o CLI option.
Declare required programs (for documentation purposes).
Require npm
Require node
Configure terminal appearance and behavior.
Set Width 800 # Terminal width in pixels
Set Height 600 # Terminal height in pixels
Set FontSize 16 # Font size in pixels
Set LetterSpacing 0 # Letter spacing in pixels
Set LineHeight 1.4 # Line height multiplier
Set Padding 16 # Terminal padding in pixels
Set Title "My Demo" # Terminal title
Set Theme dracula # Color theme
Set Template macos # Terminal template (macos, windows, minimal)
Set Watermark "\\x1b[32mby user\\x1b[0m" # Watermark text (supports ANSI)
Set PromptPrefix "\\x1b[95m❯\\x1b[0m " # Shell prompt (supports ANSI)
Set TypingSpeed 50 # Typing delay per character (ms)
Set CursorBlink true # Enable/disable cursor blinking
Set Shell bash # Shell type (for documentation)
Simulate typing text.
Type "echo 'Hello World'"
Type "Multi-line\ntext"
Type "With \ttabs"
ANSI Escape Sequences:
\\x1b- ESC character\\e- ESC character (alternative)\\n- Newline\\t- Tab
Enter # Press Enter
Backspace # Press Backspace (repeat: Backspace 5)
Space # Press Space (repeat: Space 3)
Tab # Press Tab
Left # Move cursor left (repeat: Left 5)
Right # Move cursor right (repeat: Right 3)
Up # Move up in history
Down # Move down in history
Combine modifiers with keys:
# Text selection
Shift+Left # Select character to the left
Shift+Right # Select character to the right
# Word movement
Alt+Left # Move to previous word
Alt+Right # Move to next word
# Word selection
Alt+Shift+Left # Select previous word
Alt+Shift+Right # Select next word
# Line navigation
Cmd+Left # Move to beginning of line
Cmd+Right # Move to end of line
Ctrl+A # Alternative for line start
Ctrl+E # Alternative for line end
# Word deletion
Cmd+Backspace # Delete previous word
Ctrl+W # Alternative word delete
# Other shortcuts
Ctrl+C # Send SIGINT
Ctrl+D # Send EOF
Ctrl+K # Clear the entire terminal
Cmd+K # Clear the entire terminal
Ctrl+U # Clear the entire current line
Modifiers:
Ctrl- Control keyAlt- Alt/Option keyShift- Shift keyCmd- Command key (macOS) / Windows key
Sleep 1s # Sleep for 1 second
Sleep 500ms # Sleep for 500 milliseconds
Sleep 2.5s # Sleep for 2.5 seconds
Capture a static SVG frame at the current state.
Screenshot frame.svg
Screenshot # Auto-generates filename
Auto-generated filenames follow the pattern: screenshot-1.svg, screenshot-2.svg, etc.
Copy # Copy selected text to clipboard
Paste # Paste from clipboard
Env KEY value # Set environment variable
Hide # Hide subsequent commands from output
Show # Resume showing commands
Wait 1s # Wait for duration
Wait /regex/ # Wait for text matching regex
Wait+Screen /pattern/ # Wait for screen to match
Wait+Line /pattern/ # Wait for line to match
Available themes:
catppuccinMochadraculagithubDarkgithubLightgruvboxDarkgruvboxLightmonokainordoneDarksolarizedDarksolarizedLighttokyoNightterminal
Available templates:
macos- macOS-style terminal with traffic light buttonswindows- Windows terminal styleminimal- Clean, minimal design
Lines starting with # are comments and are ignored.
# This is a comment
Type "Hello" # Inline comments are supported
Output hello.svg
Set Width 800
Set Height 600
Set Theme dracula
Set Title "Hello World"
Type "echo 'Hello, World!'"
Enter
Sleep 1s
Output keyboard.svg
Set Theme nord
Set Width 900
Set Height 600
Type "The quick brown fox"
Sleep 500ms
# Select "fox"
Left 3
Shift+Right
Shift+Right
Shift+Right
Sleep 500ms
# Replace with "cat"
Type "cat"
Sleep 1s
Output demo.svg
Set Theme tokyoNight
Set Width 1000
Set Height 700
Type "npm install"
Enter
Sleep 2s
Type "npm test"
Enter
Sleep 3s
Screenshot test-results.svg
- Always specify Output - Makes scripts self-documenting
- Use meaningful Sleep durations - 500ms-1s for user actions, 2-3s for command output
- Add comments - Explain complex sequences
- Use ANSI colors - Make prompts and output colorful
- Capture screenshots - Save important frames for static use
- Test scripts - Use
dvd validate script.cdbefore rendering
.cd- Cinema Display script file.svg- Output animated SVG file
The parser will report:
- Line numbers for syntax errors
- Unknown command names
- Invalid durations
- Mismatched quotes
Use dvd validate script.cd to check for errors before rendering.