Skip to content

Instantly share code, notes, and snippets.

@vartec
Last active March 6, 2023 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vartec/30e700586733679e4192f5c76b8b1fe2 to your computer and use it in GitHub Desktop.
Save vartec/30e700586733679e4192f5c76b8b1fe2 to your computer and use it in GitHub Desktop.
## Recodring
# install
brew install asciinema
# record
asciinema rec /tmp/foo.cast
## Convert to GIF
# install
brew install agg gifsicle
#convert
agg /tmp/foo.cast /tmp/foo.gif --font-family "FiraCode Nerd Font Mono" --renderer resvg --font-size 16 --line-height 1.2 --theme asciinema
# (optional) reduce the size of the GIF
gifsicle --lossy=80 -k 128 -O2 -Okeep-empty output.gif -o output.optimized.gif
## Convert to animated SVG
# install
npm install svg-term-cli
npm install -g git+https://github.com/miraclx/svgembed
# Convert
svg-term --in output.json --out output.svg --window # --window is needed if using embedded fonts below
# (optional) embed font, needed for eg. for Powerline glyphs
svgembed -i output.svg -o output.embed.svg -f ~/Library/Fonts/MesloLGS\ NF\ Regular.ttf --overwrite
## Pros / Cons of formats
- original Asciinema JSON is the smallest file, can only be re-played on the console
- GIF works everywhere, can get chunky, quality is kina meh
- SVG is best quality, w/o embedded font relatively small, font adds ~1-2MB; works in browsers, doesn't work in Slack nor Google Docs/Sliced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment