### Full Recording Example with Hide/Show Source: https://github.com/charmbracelet/vhs/blob/main/README.md This example demonstrates a complete recording process, including setup, hidden commands, recording, and cleanup using `Hide` and `Show`. ```elixir Output example.gif # Setup Hide Type "go build -o example . && clear" Enter Show # Recording... Type 'Running ./example' ... Enter # Cleanup Hide Type 'rm example' Enter ``` -------------------------------- ### Install VHS on Void Linux Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on Void Linux using xbps. ```sh sudo xbps-install vhs ``` -------------------------------- ### Install VHS using Nix Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on Nix systems. ```sh # Nix nix-env -iA nixpkgs.vhs ``` -------------------------------- ### Complete Tape Example Source: https://context7.com/charmbracelet/vhs/llms.txt A comprehensive example of a .tape file demonstrating various settings for terminal appearance, dependencies, interaction recording, and cleanup. ```elixir # Output targets Output demo.gif Output demo.mp4 Output golden.ascii # for CI diffing # Terminal appearance Set Shell bash Set Width 1200 Set Height 600 Set FontSize 22 Set FontFamily "JetBrains Mono" Set Theme "Catppuccin Mocha" Set Padding 20 Set Margin 40 Set MarginFill "#1e1e2e" Set WindowBar Colorful Set BorderRadius 10 Set Framerate 60 Set PlaybackSpeed 1.0 Set LoopOffset 20% # Dependency check Require gum # Build step (hidden from recording) Hide Type "go build -o myapp . && clear" Enter Show # Recorded interaction Set WaitTimeout 10s Type "./myapp --help" Enter Wait /Usage:/ Sleep 1s Ctrl+C Sleep 500ms Type "echo 'Demo complete!'" Enter Sleep 2s # Screenshot mid-recording Screenshot docs/screenshot.png # Cleanup (hidden) Hide Type "rm myapp" Enter ``` -------------------------------- ### Install VHS on Windows using Winget Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on Windows using the Winget package manager. ```sh winget install charmbracelet.vhs ``` -------------------------------- ### Install VHS using Go Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install the latest version of VHS directly using the Go toolchain. ```sh go install github.com/charmbracelet/vhs@latest ``` -------------------------------- ### Gum File Selection Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/gum/README.md Demonstrates how to use `gum file` for interactive file selection. This example simulates selecting a file and navigating directories. ```bash Output examples/gum/file.gif Type "gum file ./src" Sleep 0.5s Enter Sleep 0.5s Down@250ms 4 Up@250ms 1 Sleep 0.5s Enter Sleep 0.5s Down@250ms 4 Sleep 0.5s Up@250ms 2 Sleep 1s ``` -------------------------------- ### Install VHS using Scoop on Windows Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on Windows using the Scoop package manager. ```sh # Windows using scoop scoop install vhs ``` -------------------------------- ### Install VHS using Pacman Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on Arch Linux using the pacman package manager. ```sh # Arch Linux (btw) pacman -S vhs ``` -------------------------------- ### Enter Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Illustrates the Enter key functionality. This example includes a delay before pressing Enter. ```vhs Output examples/commands/enter.gif Set FontSize 42 Set Height 350 Sleep 1 Enter@.5 2 Sleep 1 ``` -------------------------------- ### Install VHS on Debian/Ubuntu Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS and its dependencies (ttyd, ffmpeg) on Debian-based systems using apt. ```sh # Debian/Ubuntu sudo 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 # Install ttyd from https://github.com/tsl0922/ttyd/releases sudo apt update && sudo apt install vhs ffmpeg ``` -------------------------------- ### Install VHS using Homebrew Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS on macOS or Linux using the Homebrew package manager. ```sh # macOS or Linux brew install vhs ``` -------------------------------- ### Gum Pager Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/gum/README.md Shows how to use `gum pager` to display file content interactively with custom styling. This example simulates scrolling through a file. ```bash Output examples/gum/pager.gif Set Padding 32 Set FontSize 16 Set Height 600 Type "gum pager < ~/src/gum/README.md --border normal" Sleep 0.5s Enter Sleep 1s Down@15ms 40 Sleep 0.5s Up@15ms 30 Sleep 0.5s Down@15ms 20 Sleep 2s ``` -------------------------------- ### Install VHS on Fedora/RHEL Source: https://github.com/charmbracelet/vhs/blob/main/README.md Install VHS and its dependencies (ttyd, ffmpeg) on Fedora/RHEL-based systems using yum. ```sh echo '[charm] name=Charm baseurl=https://repo.charm.sh/yum/ enabled=1 gpgcheck=1 gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo # Install ttyd from https://github.com/tsl0922/ttyd/releases sudo yum install vhs ffmpeg ``` -------------------------------- ### JQP Playback Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/jqp/README.md This snippet shows a sequence of JQP commands to record a terminal session. It includes setting dimensions, typing commands, and navigating through JSON output. ```jqp Output examples/jqp/jqp.gif Set Width 2400 Set Height 1600 Hide Type "curl https://dummyjson.com/products | jqp" Enter Sleep 1 Show Sleep 1 Type@.2'[ .products[] | select(.category=="smartphones") ]' Sleep 1 Enter Sleep 1 Tab Sleep 1 Down@25ms 20 Sleep .5 Down@25ms 20 Tab Sleep .5 Down@25ms 30 Sleep 1 Ctrl+S Sleep 3 Escape Sleep 3 ``` -------------------------------- ### Gum Table Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/gum/README.md Illustrates using `gum table` to display CSV data in a formatted table. This example simulates navigating rows within the table. ```bash Output examples/gum/table.gif Type "gum table < superhero.csv -w 2,12,5,6,6,8,4,20 --height 10" Enter Sleep 0.5s Down 10 Sleep 0.5s Down 10 Sleep 0.5s Up 10 Sleep 0.5s Enter Sleep 2s ``` -------------------------------- ### Glow Simple Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/glow/README.md This snippet demonstrates a basic Glow animation. It sets the output dimensions, types 'glow', and then simulates pressing Enter and Escape keys with pauses. ```bash Output examples/glow/glow-simple.ascii Output examples/glow/glow-simple.gif Set Width 1000 Set Height 1050 Type "glow" Enter Sleep 1s Enter Sleep 1s Escape Sleep 1s Type "q" Sleep 1s ``` -------------------------------- ### Start VHS Server Source: https://github.com/charmbracelet/vhs/blob/main/README.md Run this command to start the built-in VHS SSH server. This allows remote access to VHS with access to host commands. ```sh vhs serve ``` -------------------------------- ### Define a VHS tape file Source: https://github.com/charmbracelet/vhs/blob/main/README.md This example shows how to configure output, terminal size, font size, and simulate typing commands with pauses. ```elixir # Where should we write the GIF? Output demo.gif # Set up a 1200x600 terminal with 46px font. Set FontSize 46 Set Width 1200 Set Height 600 # Type a command in the terminal. Type "echo 'Welcome to VHS!'" # Pause for dramatic effect... Sleep 500ms # Run the command by pressing enter. Enter # Admire the output for a bit. Sleep 5s ``` -------------------------------- ### Record jqp Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md A simple VHS script to record a demonstration of the `jqp` command-line JSON processor. Ensure `jqp` is installed. ```vhs Output jqp/jqp.gif Simple jqp demo with VHS ``` -------------------------------- ### Ctrl Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Demonstrates sending Ctrl key combinations. This example shows how to send Ctrl+R. ```vhs Output examples/commands/ctrl.gif Set FontSize 42 Set Height 225 Sleep 1 Ctrl+R Sleep 1 ``` -------------------------------- ### Start the VHS SSH server Source: https://context7.com/charmbracelet/vhs/llms.txt Starts a self-hosted VHS SSH server for remote rendering. Clients can pipe `.tape` files over SSH and receive the rendered GIF back on stdout. Configuration can be done via environment variables. ```sh # Start server with defaults (localhost:1976) vhs serve # Configure via environment variables VHS_PORT=2222 VHS_HOST=0.0.0.0 VHS_AUTHORIZED_KEYS_PATH=~/.ssh/authorized_keys vhs serve # Client usage – pipe tape, receive GIF ssh vhs.example.com < demo.tape > demo.gif # Docker docker run --rm -v $PWD:/vhs ghcr.io/charmbracelet/vhs demo.tape ``` -------------------------------- ### Glow Full Example Source: https://github.com/charmbracelet/vhs/blob/main/examples/glow/README.md This snippet showcases a more advanced Glow animation. It includes setting dimensions, typing commands, navigating menus, hiding/showing the terminal, and using various key presses with timed inputs. ```bash Output examples/glow/vhs-glow.gif Output examples/glow/glow.ascii Set Width 1600 Set Height 1040 Sleep 1s Type "glow" Sleep 100ms Enter Sleep 1s Hide Tab Type "/artichoke" Enter Down 2 Show Sleep 0.5s Down 20 Hide Escape Type "l" Down 5 Show Sleep 1s Up@400ms 5 Hide Type "/ulysses" Enter Show Sleep 0.5s Down@200ms 20 Hide Escape Type "/" Show Sleep 0.5s Type@500ms "todo" Sleep 1 Hide Escape Type "/ulysses" Enter Show Sleep 0.5s Type@750ms "????" Hide Escape Type "/artichoke" Enter Type "m" Ctrl+A Right 4 Show Sleep 1s Type@250ms "Tasty " Sleep 1s Hide Escape Down 5 Type "m" Ctrl+U Show Sleep 1s Type@150ms "Your new internet thing" Sleep 3s Hide Ctrl+C Show ``` -------------------------------- ### Type Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Demonstrates the Type command for simulating keyboard input. Includes examples of normal typing and slow typing with specified delays. ```vhs Output examples/commands/type.gif Set FontSize 42 Set Height 225 Sleep 1 # Type something Type "Whatever you want" Sleep 1 Ctrl+U Sleep 1 # Type something really slowly! Type@500ms "Slow down there, partner." Sleep 1 ``` -------------------------------- ### Tab Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Illustrates the Tab command for inserting tab characters. This example includes typing and then pressing Tab with a specific delay. ```vhs Output examples/commands/tab.gif Set FontSize 42 Set Height 300 Type "cd ." Sleep 0.5s Tab@0.5s 2 Sleep 1s ``` -------------------------------- ### Space Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Shows the Space command for inserting spaces. This example inserts multiple spaces with a delay. ```vhs Output examples/commands/space.gif Set FontSize 42 Set Height 225 Sleep .25 Space 10 Sleep 1 ``` -------------------------------- ### Record Gum File Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md Use this script to record a demo of the Gum file selection tool. Ensure Gum is installed and the target file path is correct. ```vhs Output file.gif Type "gum file ./src" Sleep 1s Enter Sleep 2s Down@500ms 4 Up@500ms 1 Sleep 1s Enter Sleep 1s Down@500ms 4 Sleep 1s Up@500ms 2 Sleep 2s ``` -------------------------------- ### Hide and Show Commands - Control Capture Source: https://context7.com/charmbracelet/vhs/llms.txt Use `Hide` to pause frame recording and `Show` to resume. Commands between `Hide` and `Show` are not captured, useful for pre-recording setup. ```elixir Output demo.gif ``` ```elixir Hide ``` ```elixir Type "go build -o app . && clear" ``` ```elixir Enter ``` ```elixir Show ``` ```elixir Type "./app --help" ``` ```elixir Enter ``` ```elixir Sleep 2s ``` ```elixir Hide ``` ```elixir Type "rm app" ``` ```elixir Enter ``` -------------------------------- ### Access VHS via SSH Source: https://github.com/charmbracelet/vhs/blob/main/README.md Connect to the running VHS server using SSH. This example shows how to pipe a demo tape to the server to generate a GIF. ```sh ssh vhs.example.com < demo.tape > demo.gif ``` -------------------------------- ### Set Loop Offset Source: https://github.com/charmbracelet/vhs/blob/main/README.md Sets the starting frame for the GIF loop. This is useful for making the preview frame more engaging. ```elixir Set LoopOffset 5 # Start the GIF at the 5th frame Set LoopOffset 50% # Start the GIF halfway through ``` -------------------------------- ### Record terminal session to a tape file Source: https://github.com/charmbracelet/vhs/blob/main/README.md Start recording your terminal actions to a file named `cassette.tape`. Exit the session to stop recording. ```bash vhs record > cassette.tape ``` -------------------------------- ### Set Line Height in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Configure the spacing between lines with the `Set LineHeight` command. Example sets line height to 1.8. ```elixir Set LineHeight 1.8 ``` -------------------------------- ### Set Terminal Height in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Adjust the height of the terminal with the `Set Height` command. Example sets height to 1000. ```elixir Set Height 1000 ``` -------------------------------- ### Set Terminal Width in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Control the width of the terminal using the `Set Width` command. Example sets width to 300. ```elixir Set Width 300 ``` -------------------------------- ### VHS Neofetch Recording Script Source: https://github.com/charmbracelet/vhs/blob/main/examples/neofetch/README.md This script defines the sequence of commands and text to be recorded by VHS for the Neofetch example. It includes settings for output, typing speed, font size, and dimensions, followed by commands to simulate typing and display text. ```vhs # Source code for the VHS neofetch example. # # To run: # # vhs < neofetch.tape Output examples/neofetch/neofetch.gif Output examples/neofetch/neofetch.mp4 Output examples/neofetch/neofetch.webm Output examples/neofetch/frames/ Set TypingSpeed 75ms Set FontSize 22 Set Width 1300 Set Height 650 Type "neofetch" Sleep 500ms Enter Sleep 2s Type "Welcome to VHS!" Sleep 1 Space Type "A tool for generating terminal GIFs from code." Sleep 5s ``` -------------------------------- ### Set Padding in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Adjust the padding around the terminal frame in pixels using the `Set Padding` command. Example sets padding to 0. ```elixir Set Padding 0 ``` -------------------------------- ### Temporarily Stop Frame Capturing Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Hide` command to stop capturing frames, useful for performing hidden setup or cleanup actions before resuming with `Show`. ```elixir Hide ``` -------------------------------- ### Create a new tape file with VHS CLI Source: https://context7.com/charmbracelet/vhs/llms.txt Scaffolds a new `.tape` file with commented documentation and a default output line. The filename is provided as an argument. ```sh vhs new demo # Created demo.tape ``` -------------------------------- ### CLI: List available themes Source: https://context7.com/charmbracelet/vhs/llms.txt Prints all built-in theme names (300+ themes from base16 and popular palettes). ```APIDOC ## CLI: List available themes Prints all built-in theme names (300+ themes from base16 and popular palettes). ```sh # Plain list vhs themes # Markdown list (for embedding in docs) vhs themes --markdown ``` ``` -------------------------------- ### CLI: List Available Themes Source: https://context7.com/charmbracelet/vhs/llms.txt Use the `vhs themes` command to list available themes. The `--markdown` flag formats the output as a Markdown list. ```sh # Plain list vhs themes ``` ```sh # Markdown list (for embedding in docs) vhs themes --markdown ``` -------------------------------- ### Set Font Family in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Set FontFamily` command to specify the font for the terminal. Example uses 'Monoflow'. ```elixir Set FontFamily "Monoflow" ``` -------------------------------- ### Set Letter Spacing in VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Modify the spacing between letters (tracking) using `Set LetterSpacing`. Example sets spacing to 20. ```elixir Set LetterSpacing 20 ``` -------------------------------- ### Format Text with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Demonstrates how to format text with colors and styles using CLI UI's formatting capabilities. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/format.gif Set FontSize 32 Set Width 2200 Set Height 400 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type 'puts CLI::UI.fmt "{{red:Red}} {{green:Green}}"' Sleep .5 Enter Sleep 5 ``` -------------------------------- ### Specify Output Formats Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Output` command to define the file path and format for the rendered output. Multiple output formats can be specified. ```elixir Output out.gif ``` ```elixir Output out.mp4 ``` ```elixir Output out.webm ``` ```elixir Output frames/ # a directory of frames as a PNG sequence ``` -------------------------------- ### Set Theme Source: https://context7.com/charmbracelet/vhs/llms.txt Apply a predefined named theme or define a custom theme using inline JSON. ```vhs-config Set Theme "Catppuccin Mocha" ``` ```vhs-config Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "magenta": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightMagenta": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selection": "#3d3c58", "cursor": "#b3b0d6" } ``` -------------------------------- ### List All GitHub Pull Requests Source: https://github.com/charmbracelet/vhs/blob/main/examples/gh-cli/README.md Use this command to display all pull requests in a repository. It simulates typing the command and waiting for the output. ```bash Output examples/gh-cli/gh-pr.gif Type "gh pr list --state all" Sleep 500ms Enter Sleep 5s ``` -------------------------------- ### Run VHS using Docker Source: https://github.com/charmbracelet/vhs/blob/main/README.md Execute VHS with a Docker container, mounting the current directory to access tape files and output GIFs. ```sh docker run --rm -v $PWD:/vhs ghcr.io/charmbracelet/vhs .tape ``` -------------------------------- ### Configure terminal and video settings in a tape file Source: https://context7.com/charmbracelet/vhs/llms.txt Configures the recording environment, including shell, font size, family, spacing, line height, and dimensions. All `Set` directives must appear at the top of the tape file. ```elixir # Shell (bash, zsh, fish, nu, osh, powershell, pwsh, cmd, xonsh) Set Shell fish # Typography Set FontSize 22 Set FontFamily "JetBrains Mono" Set LetterSpacing 1 Set LineHeight 1.2 # Dimensions (pixels) Set Width 1200 Set Height 600 ``` -------------------------------- ### Assert binary dependencies in a tape file Source: https://context7.com/charmbracelet/vhs/llms.txt Checks for the existence of a program on `$PATH` before tape execution. Must appear before interactive commands. Exits with an error if the program is missing. ```elixir Require gum Require glow Require ffmpeg # After declaring requirements, proceed with interactive commands Type "gum confirm 'Continue?'" Enter ``` -------------------------------- ### Record GitHub CLI Issue List Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md This script records a demonstration of listing GitHub issues using the `gh` CLI. It includes typing the command, entering, and viewing the output. ```vhs Output gh-issue.gif Type "gh issue list" Sleep 500ms Enter 1 Sleep 4s Ctrl+L Sleep 500ms Type "gh issue view 19" Sleep 500ms Enter Sleep 5s ``` -------------------------------- ### Prompt User for Text Input with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Demonstrates how to prompt the user for text input, including setting a default value, using CLI UI's ask function. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/text-prompt.ascii Output examples/cli-ui/text-prompt.gif Set FontSize 32 Set Width 2200 Set Height 500 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type "CLI::UI.ask('Is CLI UI Awesome?', default: 'It is great!')" Sleep .5 Enter Sleep 1 Type "I love it!" Sleep 1 Enter Sleep 3 ``` -------------------------------- ### Key Commands - Modifier Combinations Source: https://context7.com/charmbracelet/vhs/llms.txt Demonstrates using modifier keys (Ctrl, Alt, Shift) in combination with other keys. ```elixir Ctrl+C ``` ```elixir Ctrl+L ``` ```elixir Ctrl+R ``` ```elixir Ctrl+Shift+P ``` ```elixir Ctrl+Alt+Delete ``` ```elixir Alt+. ``` ```elixir Alt+L ``` ```elixir Shift+Tab ``` ```elixir Shift+Enter ``` -------------------------------- ### View and Interact with GitHub Issues Source: https://github.com/charmbracelet/vhs/blob/main/examples/gh-cli/README.md This snippet shows how to list issues, select one, view its details, and clear the screen. It's useful for managing issue trackers. ```bash Output examples/gh-cli/gh-issue.gif Type "gh issue list" Sleep 500ms Enter 1 Sleep 4s Ctrl+L Sleep 500ms Type "gh issue view 19" Sleep 500ms Enter Sleep 5s ``` -------------------------------- ### Simulate Enter Key Press Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Enter` command to simulate pressing the enter key. It can be repeated. ```elixir Enter 2 ``` -------------------------------- ### Simulate Space Bar Press Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Space` command to simulate pressing the space bar. It can be repeated. ```elixir Space 10 ``` -------------------------------- ### Record GitHub CLI Pull Request List Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md Record a demonstration of listing all GitHub pull requests using the `gh` CLI. This script types the command and waits for the output. ```vhs Output gh-pr.gif Type "gh pr list --state all" Sleep 500ms Enter Sleep 5s ``` -------------------------------- ### Record Simple Glow Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md This VHS script records a basic demonstration of the Glow tool for rendering Markdown. It includes typing 'glow', entering, and exiting. ```vhs Output glow-simple.ascii Output glow-simple.gif Set Width 1000 Set Height 1000 Type "glow" Enter Sleep 1s Enter Sleep 1s Escape Sleep 1s Type "q" Sleep 1s ``` -------------------------------- ### Simulate Page Up/Down Key Presses Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use `PageUp` or `PageDown` commands to simulate pressing these keys. They can be repeated. ```elixir PageUp 3 PageDown 5 ``` -------------------------------- ### Run a tape file with VHS CLI Source: https://context7.com/charmbracelet/vhs/llms.txt Execute a `.tape` file and write output files. Use `-o` to override output paths or pipe input via stdin. Options like `--publish` and `--quiet` are available. ```sh vhs demo.tape vhs demo.tape -o my-demo.gif cat demo.tape | vhs vhs demo.tape --publish vhs demo.tape --quiet ``` -------------------------------- ### Create Nested Frames with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Illustrates how to create nested frames for organizing content within the terminal using CLI UI. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/nested-frames.gif Set FontSize 32 Set Width 2000 Set Height 750 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type "CLI::UI::Frame.open('Frame 1') do" Enter Type " CLI::UI::Frame.open('Frame 2') { puts 'inside frame 2' }" Enter Type " puts 'inside frame 1'" Enter Type "end" Sleep 1 Enter Sleep 3 ``` -------------------------------- ### Arrow Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Demonstrates the use of arrow keys for navigation. Adjusts font size and height for better visibility. ```vhs Output examples/commands/arrow.gif Set FontSize 42 Set Height 225 Type "Navigate around" Sleep .25 Left 10 Sleep 1 Right@50ms 10 Sleep 1 ``` -------------------------------- ### Specify Required Programs Source: https://github.com/charmbracelet/vhs/blob/main/README.md The `Require` command ensures that specific programs are available in the `$PATH` before executing a tape. This helps catch missing dependencies early. These commands must be at the top of the tape file. ```elixir # A tape file that requires gum and glow to be in the $PATH Require gum Require glow ``` -------------------------------- ### Use Spinner Widget with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Demonstrates the use of a spinner widget to indicate ongoing processes in the CLI. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/spinner.gif Set FontSize 32 Set Width 2200 Set Height 400 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type "CLI::UI::Spinner.spin('Spinning...') { sleep 3 }" Sleep .5 Enter Sleep 5 ``` -------------------------------- ### Create a new VHS tape file Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use this command to generate a new `.tape` file for defining your terminal session. ```sh vhs new demo.tape ``` -------------------------------- ### Simulate Arrow Key Presses and Typing Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use arrow key commands (`Up`, `Down`, `Left`, `Right`) to navigate and `Type` to input text. Commands can be repeated. ```elixir Up 2 Down 2 Left Right Left Right Type "B" Type "A" ``` -------------------------------- ### Set Theme in VHS (JSON) Source: https://github.com/charmbracelet/vhs/blob/main/README.md Apply a custom theme by providing a JSON string with color definitions to the `Set Theme` command. ```elixir Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "magenta": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightMagenta": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selection": "#3d3c58", "cursor": "#b3b0d6" } ``` -------------------------------- ### Publish a GIF with VHS CLI Source: https://context7.com/charmbracelet/vhs/llms.txt Uploads a rendered GIF to `vhs.charm.sh` via SSH and returns a shareable URL. It auto-generates an Ed25519 key pair on first use. Use `--quiet` to print only the URL. ```sh vhs publish demo.gif # Output: # Share your GIF with Markdown: # ![Made with VHS](https://vhs.charm.sh/vhs-abc123.gif) # ... # https://vhs.charm.sh/vhs-abc123.gif # Quiet mode – prints URL only vhs publish demo.gif --quiet ``` -------------------------------- ### Display Status Widget with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Illustrates how to display a dynamic status widget, potentially showing progress or state, within the CLI. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/status-widget.gif Set FontSize 32 Set Width 2200 Set Height 400 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type 'CLI::UI::Spinner.spin("Building: {{widget/status:1:2:3:4}}") { |spinner| sleep 3 }' Sleep .5 Enter Sleep 5 ``` -------------------------------- ### Hide and Show Commands Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Demonstrates the Hide and Show commands to control the visibility of typed text. Useful for sensitive information or to create specific visual effects. ```vhs Output examples/commands/hide.gif Set FontSize 42 Set Height 300 Hide Type "You won't see this being typed." Ctrl+C Show Type "You will see this being typed." Sleep 2 ``` ```vhs Output examples/commands/show.gif Hide Type "export HIDDEN=wow" Enter Ctrl+L Show Type "echo $HIDDEN" Enter Sleep 1 ``` -------------------------------- ### Simulate Tab Key Press with Delay Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Tab` command to simulate pressing the tab key. You can specify a delay in milliseconds and repeat the action. ```elixir Tab@500ms 2 ``` -------------------------------- ### Evaluate() Programmatic Go API Source: https://context7.com/charmbracelet/vhs/llms.txt Use the Evaluate function to programmatically render tapes from Go code. It takes a context, tape string, and an output writer, returning any errors encountered during evaluation. ```go package main import ( "context" "fmt" "os" vhs "github.com/charmbracelet/vhs" ) func main() { tape := ` Output /tmp/demo.gif Set Width 1200 Set Height 600 Set FontSize 22 Type "echo 'Hello from VHS'" Enter Sleep 2s ` errs := vhs.Evaluate(context.Background(), tape, os.Stdout) if len(errs) > 0 { for _, err := range errs { fmt.Fprintln(os.Stderr, err) } os.Exit(1) } fmt.Println("Rendered: /tmp/demo.gif") } ``` -------------------------------- ### Display Progress Bar with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Shows how to implement a progress bar for long-running tasks using CLI UI's progress feature. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/progress.gif Set FontSize 32 Set Width 2200 Set Height 400 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type "CLI::UI::Progress.progress { |bar| 100.times { sleep 0.02; bar.tick } }" Sleep .5 Enter Sleep 5 ``` -------------------------------- ### Key Commands - Navigation Source: https://context7.com/charmbracelet/vhs/llms.txt Simulates common navigation key presses like Up, Down, Left, Right, PageUp, PageDown, ScrollUp, and ScrollDown, with optional delays and counts. ```elixir Up 2 ``` ```elixir Down@100ms 3 ``` ```elixir Left ``` ```elixir Right 5 ``` ```elixir PageUp ``` ```elixir PageDown 2 ``` ```elixir ScrollUp 10 ``` ```elixir ScrollDown@50ms 4 ``` -------------------------------- ### Set Theme in VHS (Name) Source: https://github.com/charmbracelet/vhs/blob/main/README.md Apply a predefined theme by its name using the `Set Theme` command. Refer to `vhs themes` or `THEMES.md` for available options. ```elixir Set Theme "Catppuccin Frappe" ``` -------------------------------- ### Record Advanced Glow Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md Record a more complex demonstration of Glow, showcasing navigation and search within Markdown files. This script uses various commands like `Hide`, `Show`, `Tab`, and cursor movements. ```vhs Output vhs-glow.gif Output glow.ascii Set Width 1600 Set Height 1040 Sleep 1s Type "glow" Sleep 100ms Enter Sleep 1s Hide Tab Type "/artichoke" Enter Down 2 Show Sleep 0.5s Down 20 Hide Escape Type "l" Down 5 Show Sleep 1s Up@400ms 5 Hide Type "/ulysses" Enter Show Sleep 0.5s Down@200ms 20 Hide Escape Type "/" Show Sleep 0.5s Type@500ms "todo" Sleep 1 Hide Escape Type "/ulysses" Enter Show Sleep 0.5s Type@750ms "????" Hide Escape Type "/artichoke" Enter Type "m" Ctrl+A Right 4 Show Sleep 1s Type@250ms "Tasty " Sleep 1s Hide Escape Down 5 Type "m" Ctrl+U Show Sleep 1s Type@150ms "Your new internet thing" Sleep 3s Hide Ctrl+C Show ``` -------------------------------- ### Declare output files in a tape file Source: https://context7.com/charmbracelet/vhs/llms.txt Specifies one or more output files for the rendered video. The extension determines the format (e.g., `.gif`, `.mp4`, `.webm`). A trailing slash indicates a PNG frame sequence. ```elixir Output demo.gif # animated GIF Output demo.mp4 # MP4 video Output demo.webm # WebM video Output demo.ascii # plain-text golden file for CI testing Output demo.txt # alias for .ascii Output frames/ # PNG frame sequence (directory, trailing slash required) ``` -------------------------------- ### Backspace Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Illustrates the backspace functionality for deleting characters. Includes typing with a specific delay and then backspacing. ```vhs Output examples/commands/backspace.gif Set FontSize 42 Set Height 225 Type@50ms "Delete anything..." Backspace 18 Sleep 1 ``` -------------------------------- ### Record Gum Table Demo with VHS Source: https://github.com/charmbracelet/vhs/blob/main/examples/README.md Record a demo of the Gum table tool, which displays CSV data in a formatted table. Ensure the `superhero.csv` file is accessible. ```vhs Output table.gif Type "gum table < superhero.csv -w 2,12,5,6,6,8,4,20 --height 10" Enter Sleep 1s Down@200ms 10 Sleep 1s Down@200ms 10 Sleep 1s Up@200ms 10 Sleep 1s Enter Sleep 3s ``` -------------------------------- ### Type Command - Quote Styles Source: https://context7.com/charmbracelet/vhs/llms.txt Demonstrates using different quote styles (double, single, backticks) for strings within the Type command. ```elixir Type "double quotes work fine" ``` ```elixir Type 'use single when string has "double" quotes' ``` ```elixir Type `VAR="value with 'both' kinds"` ``` -------------------------------- ### Type Command - Basic Typing Source: https://context7.com/charmbracelet/vhs/llms.txt Simulates typing a string character by character into the terminal. ```elixir Type "echo 'Hello, World!'" ``` -------------------------------- ### Resume Frame Capturing Source: https://github.com/charmbracelet/vhs/blob/main/README.md The `Show` command resumes frame capturing after it has been paused by the `Hide` command. ```elixir Hide Type "You won\'t see this being typed." Show Type "You will see this being typed." ``` -------------------------------- ### Key Commands - Editing Source: https://context7.com/charmbracelet/vhs/llms.txt Simulates editing key presses including Enter, Backspace, Delete, Insert, Tab, Space, and Escape, with optional delays and counts. ```elixir Enter ``` ```elixir Enter 2 ``` ```elixir Backspace 18 ``` ```elixir Backspace@200ms 5 ``` ```elixir Delete 3 ``` ```elixir Insert ``` ```elixir Tab 2 ``` ```elixir Tab@500ms 1 ``` ```elixir Space 10 ``` ```elixir Escape ``` -------------------------------- ### Display Symbols with CLI UI Source: https://github.com/charmbracelet/vhs/blob/main/examples/cli-ui/README.md Shows how to render various symbols like checkmarks, warnings, and errors within the CLI output using CLI UI. Requires enabling StdoutRouter. ```ruby Output examples/cli-ui/symbols.gif Set FontSize 32 Set Width 2200 Set Height 400 Hide Type "irb --noautocomplete" Enter Type "require 'cli/ui'" Enter Type "CLI::UI::StdoutRouter.enable" Enter Ctrl+L Show Type 'puts CLI::UI.fmt "{{*}} {{v}} {{?}} {{x}}"' Sleep .5 Enter Sleep 5 ``` -------------------------------- ### Configure and Play Slides Animation Source: https://github.com/charmbracelet/vhs/blob/main/examples/slides/README.md This script configures the slide dimensions, framerate, and padding, then controls the playback of text typing and screen visibility to create an animation. Use this to define the visual and timing aspects of your terminal slides. ```shell Output examples/slides/slides.gif Set FontSize 32 Set Padding 0 Set Framerate 1 Set Width 1600 Set Height 1200 Hide Type "slides" Enter Show Sleep 1s Type@1s "n" Sleep 1s Ctrl+E Sleep 1s Type@1s "nnn" Sleep 1s ``` -------------------------------- ### Set Playback and Loop Options Source: https://context7.com/charmbracelet/vhs/llms.txt Control the playback speed of the recording and the offset for GIF looping. ```vhs-config Set PlaybackSpeed 1.0 ``` ```vhs-config Set LoopOffset 20% ``` -------------------------------- ### Output Tape as ASCII for CI Source: https://github.com/charmbracelet/vhs/blob/main/README.md Configure VHS to output the tape content in ASCII format. This is useful for generating golden files for integration testing in CI pipelines. ```elixir Output golden.ascii ``` -------------------------------- ### Source Commands from Another Tape Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use the `Source` command to execute commands defined in another tape file. This is useful for modularizing tape definitions. ```elixir Source config.tape ``` -------------------------------- ### Set Appearance Properties Source: https://context7.com/charmbracelet/vhs/llms.txt Customize the visual appearance of the terminal window, including padding, margins, border radius, and window bar style. ```vhs-config Set Padding 20 ``` ```vhs-config Set Margin 40 ``` ```vhs-config Set MarginFill "#6B50FF" ``` ```vhs-config Set BorderRadius 10 ``` ```vhs-config Set WindowBar Colorful ``` ```vhs-config Set WindowBarSize 28 ``` ```vhs-config Set CursorBlink false ``` -------------------------------- ### Apply a Custom Theme to VHS Recording Source: https://github.com/charmbracelet/vhs/blob/main/examples/settings/README.md Define a custom color theme for the recording, including all standard terminal colors and selection/cursor highlights. ```shell Output examples/settings/set-theme.gif Set FontSize 42 Set Height 225 Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "purple": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightPurple": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selectionBackground": "#3d3c58", "cursorAccent": "#b3b0d6", "cursor": "#b3b0d6" } Type "I can't make up my mind." Sleep 1 ``` -------------------------------- ### Record terminal actions to a tape file Source: https://context7.com/charmbracelet/vhs/llms.txt Launches a PTY session to record key presses and translate them into tape commands printed to stdout. The output can be piped to a file for later replay. ```sh # Record interactive session; pipe to file vhs record > cassette.tape # Record with a specific shell vhs record --shell fish > cassette.tape # Then replay the recording vhs cassette.tape ``` -------------------------------- ### Evaluate() — programmatic Go API Source: https://context7.com/charmbracelet/vhs/llms.txt The core engine function. Takes a tape string, evaluates all commands, and renders the output. Used internally by the CLI and SSH server; can be called from Go code. ```APIDOC ## `Evaluate()` — programmatic Go API The core engine function. Takes a tape string, evaluates all commands, and renders the output. Used internally by the CLI and SSH server; can be called from Go code. ```go package main import ( "context" "fmt" "os" vhs "github.com/charmbracelet/vhs" ) func main() { tape := ` Output /tmp/demo.gif Set Width 1200 Set Height 600 Set FontSize 22 Type "echo 'Hello from VHS'" Enter Sleep 2s ` errs := vhs.Evaluate(context.Background(), tape, os.Stdout) if len(errs) > 0 { for _, err := range errs { fmt.Fprintln(os.Stderr, err) } os.Exit(1) } fmt.Println("Rendered: /tmp/demo.gif") } ``` ``` -------------------------------- ### Set Wait Timeout and Pattern Source: https://context7.com/charmbracelet/vhs/llms.txt Configure the default timeout for wait operations and the regex pattern to match. ```vhs-config Set WaitTimeout 30s ``` ```vhs-config Set WaitPattern /\$\s*$/ ``` -------------------------------- ### Publish a GIF using VHS Source: https://github.com/charmbracelet/vhs/blob/main/README.md Upload a generated GIF to `vhs.charm.sh` for easy sharing. The command outputs links for browser, HTML, and Markdown embedding. ```sh vhs publish demo.gif ``` -------------------------------- ### Copy and Paste Commands - Clipboard Operations Source: https://context7.com/charmbracelet/vhs/llms.txt Use `Copy` to write a string to the system clipboard and `Paste` to type the clipboard content into the terminal. ```elixir Copy "https://github.com/charmbracelet/vhs" ``` ```elixir Type "open " ``` ```elixir Sleep 200ms ``` ```elixir Paste ``` ```elixir Enter ``` -------------------------------- ### Backspace Key Press Source: https://github.com/charmbracelet/vhs/blob/main/README.md Simulates pressing the Backspace key a specified number of times. ```elixir Backspace 18 ``` -------------------------------- ### Source Command - Include Another Tape Source: https://context7.com/charmbracelet/vhs/llms.txt Inlines commands from another `.tape` file. `Output` and `Source` commands within the sourced tape are ignored, and nested sourcing is not permitted. ```elixir Source config.tape ``` ```elixir Type "echo 'shared config applied'" ``` ```elixir Enter ``` ```elixir Sleep 1s ``` -------------------------------- ### Set Typing Speed and Framerate Source: https://context7.com/charmbracelet/vhs/llms.txt Configure the typing speed between characters and the capture framerate for the recording. ```vhs-config Set TypingSpeed 50ms ``` ```vhs-config Set Framerate 60 ``` -------------------------------- ### Wait for Regular Expression Match Source: https://github.com/charmbracelet/vhs/blob/main/README.md The `Wait` command pauses recording until a regular expression matches. It supports specifying a timeout, scope (Screen or Line), and delay. ```elixir Wait Wait /World/ Wait+Screen /World/ Wait+Line /World/ Wait@10ms /World/ Wait+Line@10ms /World/ ``` -------------------------------- ### Copy and Paste Text Source: https://github.com/charmbracelet/vhs/blob/main/README.md Use `Copy` to place text onto the clipboard and `Paste` to insert it into the terminal. Useful for inserting URLs or complex strings. ```elixir Copy "https://github.com/charmbracelet" Type "open " Sleep 500ms Paste ``` -------------------------------- ### Set Terminal Shell Source: https://github.com/charmbracelet/vhs/blob/main/README.md Configure the shell environment for the recording session using the `Set Shell` command. This setting should be at the top of the tape file. ```elixir Set Shell fish ``` -------------------------------- ### Wait Command - Wait for Output Source: https://context7.com/charmbracelet/vhs/llms.txt Blocks execution until a regex pattern matches the terminal output. Can specify matching on the current line or the full screen, with optional timeout overrides. ```elixir Wait ``` ```elixir Wait /\$\s*$/ ``` ```elixir Wait+Screen /Done!/ ``` ```elixir Wait+Line /\$ $/ ``` ```elixir Wait@5s /ready/ ``` ```elixir Wait+Screen@30s /build succeeded/ ``` -------------------------------- ### Generate a GIF from a VHS tape file Source: https://github.com/charmbracelet/vhs/blob/main/README.md After creating and editing your `.tape` file, use this command to generate the terminal GIF. ```sh vhs demo.tape ``` -------------------------------- ### Comment Command Source: https://github.com/charmbracelet/vhs/blob/main/examples/commands/README.md Shows how to use comments in VHS scripts. Comments are ignored by the parser and can be used for notes or temporarily disabling commands. ```vhs Output examples/commands/comment.gif Set Height 500 Set Width 1000 # This is a comment. # These are ignored by the parser so you can write whatever you want! # Quickly comment out a command you don't need. # Type "Hello, world!" Sleep 1 ``` -------------------------------- ### Screenshot Command - Capture Frame Source: https://context7.com/charmbracelet/vhs/llms.txt Saves the current terminal frame as a PNG image to the specified file path. ```elixir Type "ls -la" ``` ```elixir Enter ``` ```elixir Sleep 500ms ``` ```elixir Screenshot examples/screenshot.png ```