Created
April 18, 2018 13:39
-
-
Save gcaracuel/91838cfd57e0648c4102eca281a01b3c to your computer and use it in GitHub Desktop.
Downloads asciinema-player and build an index.html file to share asciicast ofline
This file contains 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 | |
current_path=$(pwd) | |
# Download latest version files in the current PATH | |
curl -L -O $(curl -s https://api.github.com/repos/asciinema/asciinema-player/releases/latest | jq -r '.assets[0].browser_download_url') &&\ | |
curl -L -O $(curl -s https://api.github.com/repos/asciinema/asciinema-player/releases/latest | jq -r '.assets[1].browser_download_url') | |
# Modify HTML to point to your local asciinema recording file | |
asciicast_file=$(find /tmp -maxdepth 1 -name \*.cast -printf "%T@ %Tc %p\n" | sort -n | head -1 | cut -f 8 -d' ') | |
cp ${asciicast_file} ${current_path}/session.cast | |
echo """<html> | |
<head> | |
<link rel=\"stylesheet\" type=\"text/css\" href=\"./asciinema-player.css\" /> | |
</head> | |
<body> | |
<asciinema-player src=\"${current_path}/session.cast\"></asciinema-player> | |
<script src=\"${current_path}/asciinema-player.js\"></script> | |
</body> | |
</html>""" > index.html | |
echo "Open ${current_path}/index.html using your favorite browser" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment