-
Install asciinema
-
Record a command line interaction
asciinema rec /path/to/asciinema-file
-
When prompted, save locally with ctrl-c
-
Optionally, view the video
asciinema play /path/to/asciinema-file
-
The file that asciinema creates is pure text and easy to understand. If you need to fix typing errors, do it now. Don't worry about timing information as that will be normalized in the next step
-
Run
speed-up-asciicinema.js
with the input file, the ms between each keystroke and the ms pause at the end of the script. The file is saved to/path/to/asciinema-file.updated
node speed-up-asciicinema.js /path/to/asciinema-file 100 5000
-
Install
svg-term-cli
npm install -g svg-term-cli
-
Convert the modified asciinema document to an SVG. See the SVG Term docs for options
cat /path/to/asciinema-file.updated | svg-term --out /path/to/asciinema-file.svg --window
Last active
March 26, 2018 16:23
-
-
Save tollmanz/e5b8b677c97922c61d7c82cc0ffd97d8 to your computer and use it in GitHub Desktop.
Create an uniformly typed SVG of a terminal recording using asciinema and svg-term-cli
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
const fs = require('fs'); | |
const args = process.argv; | |
const file = args[2]; | |
const spaceInMs = parseInt(args[3], 10); | |
const endSpace = parseInt(args[4], 10) || 0; | |
const lines = fs.readFileSync(file).toString().trim().split('\n'); | |
let time = 0; | |
const reformatted = lines.map(line => { | |
const regex = /^\[[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+),/; | |
if (line.match(regex)) { | |
const timeInSeconds = time/1000; | |
line = line.replace(regex, `[${timeInSeconds},`); | |
} | |
time += spaceInMs; | |
return line; | |
}); | |
if (endSpace > 0) { | |
reformatted.push(`[${(time + endSpace)/1000}, "o", ""]`); | |
} | |
const joinedLines = reformatted.join('\n'); | |
const newFile = `${file}.updated`; | |
fs.writeFileSync(newFile, joinedLines); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment