Skip to content

Instantly share code, notes, and snippets.

@veracioux
Created October 16, 2021 18:42
Show Gist options
  • Select an option

  • Save veracioux/5f7d2ebf634cc3fb1d631b78e6230864 to your computer and use it in GitHub Desktop.

Select an option

Save veracioux/5f7d2ebf634cc3fb1d631b78e6230864 to your computer and use it in GitHub Desktop.
Record a command with asciinema, upload it and create an animated SVG for inclusion into a README
#!/usr/bin/env sh
# NOTE: Change this to suit your needs
TERM_WIDTH="<YOUR WIDTH>"
TERM_HEIGHT="<YOUR HEIGHT>"
RECORDED_COMMAND="<YOUR COMMAND>"
alias copy='xsel -b'
# Dependencies:
# - asciinema (https://github.com/asciinema/asciinema)
# - svg-term (https://github.com/marionebl/svg-term-cli)
# - xsel
rm -f /tmp/bakfile_bak.cast
# Change terminal width and height
stty cols "$TERM_WIDTH" rows "$TERM_HEIGHT"
# Record the command
asciinema rec -c "$RECORDED_COMMAND" /tmp/bakfile_bak.cast
# Upload to asciinema.org
output="$(asciinema upload /tmp/bakfile_bak.cast)"
echo "$output"
# Copy URL to clipboard
echo "$output" | grep 'https:' | sed 's/^\s*//' | copy
# Create local SVG animation
cat /tmp/bakfile_bak.cast | svg-term --out bak_demo.svg
echo "SVG animation saved as 'bak_demo.svg'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment