- Notifications
You must be signed in to change notification settings - Fork11
Turn R scripts into terminal screencasts
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdNotificationsYou must be signed in to change notification settings
r-lib/asciicast
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Turn R scripts into terminal screencasts
asciicast takes an R script and turns it into anasciinema cast. It can simulate typing, andrecords all terminal output in real time as it happens.
- Input is an R script, output is av2 asciicastrecording.
- Record all terminal output in real time, as it happens.
- Simulate typing in the commands, with a configurable, randomizedspeed.
- Alternatively, whole comment blocks or expressions can just appearon the screen.
- Convert casts to SVG images usingsvg-term. The package comeswith its own svg-term bundle, no external dependencies are needed.
- Render a single frame of a cast as an SVG image.
- Configurable delay at the beginning, at the end and betweenparagraphs.
- HTML widget, to be used in Rmarkdowndocuments, e.g. in vignettes.
- Read casts from asciinema JSON files (version 2), or fromhttps://asciinema.org directly.
- Special knitr engine to create R markdown files with ascii casts.See the
asciicast-demovignette. - Create ascii casts in GitHub READMEs via animated SVG files. See anexample in
inst/examplesor theREADME.Rmdsource of the READMEfile you are reading.
- asciicast works best in an UTF-8 locale. It also works well if alloutput is ASCII, but non-ASCII output might cause problems(#36).
You can install the released version of asciicast fromCRAN:
install.packages("asciicast")See theinst/examplesdirectoryfor these examples.
The input script:
print("Hello world!")The result:
Input script that uses asciicast itself:
#' Title: asciicast example recorded in asciicast#' Empty_wait: 3#' End_wait: 20# An example for using asciicast, recorded in asciicast itself! #!# First, save the R code you want to run, in a script file. #!# The file can contain any code, including interactive code, #!# as long as it is a syntactically valid R file. #!# Second, perform the recording with the `record()` function. #!# We are recording an example file now, that comes with the package. #!src<- system.file("examples","hello.R",package="asciicast")cast<-asciicast::record(src)# `cast` is an `asciicast` object, which has some metadata and the #!# recording itself: #!cast# You can write `cast` to a JSON file that can be played by any #!# asciinema player. Or you can write it to an SVG file that can #!# be embedded into a web page, or a GitHub README. #!svg<- tempfile(fileext=".svg")asciicast::write_svg(cast,svg,window=TRUE)
Input script with errors:
#' End_wait: 20# Demonstrate that errors are handled well# Base R errorlibrary("not-this-really")traceback()# callr errors are saved to `.Last.error`, including a stack tracelibrary(cli)callr::r(function() library("another-failure")).Last.error
- asciinema:https://asciinema.org/
- The original terminal session recorder:https://github.com/asciinema/asciinema
- svg-term:https://github.com/marionebl/svg-term,https://github.com/marionebl/svg-term-cli
MIT @RStudio
About
Turn R scripts into terminal screencasts
Resources
License
Unknown, MIT licenses found
Licenses found
Unknown
LICENSEMIT
LICENSE.mdCode of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.