Skip to content

Instantly share code, notes, and snippets.

@nicolemon
Created December 10, 2019 23:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolemon/e7001e944c283d8605390c26959fbc7e to your computer and use it in GitHub Desktop.
Save nicolemon/e7001e944c283d8605390c26959fbc7e to your computer and use it in GitHub Desktop.
asciigifs
#!/usr/bin/env bash
# Convert your asciinema cast into a gif
# https://github.com/asciinema/asciicast2gif#docker-image
# https://brunswyck.blog/2017/05/17/record-your-bash-shell-and-upload-as-a-gif-file/
# usage: in directory containing .cast file and this script: ./asciigifs <file name without .cast extension>
command -v docker >/dev/null 2>&1 || (echo "docker must be installed" && exit 1)
main() {
fname="$1"
if [ -f "$fname.cast" ]; then
ispulled=$(docker image ls asciinema/asciicast2gif --format "{{.Repository}}")
[ -z "$ispulled" ] && docker pull asciinema/asciicast2gif
echo "creating '$fname.gif' from '$fname.cast'"
docker run --rm --network host -v "$(pwd)":/data asciinema/asciicast2gif -t asciinema -s 2 "$fname.cast" "$fname.gif"
else
echo "can't find file '$fname.cast' in this directory" && exit 1
fi
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment