Created
December 10, 2019 23:45
-
-
Save nicolemon/e7001e944c283d8605390c26959fbc7e to your computer and use it in GitHub Desktop.
asciigifs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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