Generate and run Charmbracelet VHS terminal tapes
0

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 92.9%
Dune 1.8%
Other 5.2%
11 1 0

Clone this repository

https://git.vm.fail/gazagnaire.org/ocaml-vhs https://git.vm.fail/did:plc:qbk2dbrcbhh53otsjxfmbxqk
ssh://git@git.recoil.org:2222/gazagnaire.org/ocaml-vhs ssh://git@git.recoil.org:2222/did:plc:qbk2dbrcbhh53otsjxfmbxqk

For self-hosted knots, clone URLs may differ based on your setup.


README.md

vhs#

Generate Charmbracelet VHS .tape files from OCaml and optionally run the vhs command-line tool.

let tape =
  Vhs.tape
    [
      Vhs.output "demo.gif";
      Vhs.set (Shell "bash");
      Vhs.set (Font_size 18);
      Vhs.set (Width 1000);
      Vhs.set (Height 560);
      Vhs.type' "dune test";
      Vhs.enter ();
      Vhs.sleep (S 2.);
    ]

let () = Vhs.write_file ~path:"demo.tape" tape

Rendering is a thin wrapper around the external vhs binary:

Eio_main.run @@ fun env ->
let proc = Eio.Stdenv.process_mgr env in
match Vhs.render ~proc ~path:"demo.tape" tape with
| Ok () -> ()
| Error e -> Fmt.epr "%a@." Vhs.pp_error e

Record a cram test#

vhs-cram turns the commands and checked output in a cram transcript into a recording. A setup script can start the program under test without showing that setup in the GIF:

$ vhs-cram --setup setup.sh --output demo.gif demo.t

This keeps the executable documentation and its animated demonstration driven by the same source. Use --width for unusually wide terminal output.

Installation#

Install with opam:

$ opam install vhs

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install vhs