Skip to content

Instantly share code, notes, and snippets.

@gcaracuel
Created April 18, 2018 13:39
Show Gist options
  • Save gcaracuel/91838cfd57e0648c4102eca281a01b3c to your computer and use it in GitHub Desktop.
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
#!/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