Skip to content

This is for expert use, if you want to run multiple recordings in the same process.

Usage

asciicast_start_process(
  startup = NULL,
  timeout = 10,
  record_env = NULL,
  interactive = TRUE,
  locales = get_locales(),
  options = NULL,
  show_output = FALSE
)

Arguments

startup

Quoted language object to run in the subprocess before starting the recording.

timeout

Idle timeout, in seconds If the R subprocess running the recording does not answer within this limit, it is killed and the recording stops.

record_env

Environment variables to set for the R subprocess.

interactive

Whether to run R in interactive mode. Note that in interactive mode R might ask for terminal input.

locales

Locales to set in the asciicast subprocess. Defaults to the current locales in the main R process. Specify a named character vector here to override some of the defaults. See also get_locales().

options

Options to set in the subprocess, a named list. They are deparsed to code, and then the code setting them is executed in the subprocess. See asciicast_options() for the defaults. Supply a named list here to override the defaults or set additionsl ones. Passing large and/or complicated options here might not work, or might be slow.

show_output

Whether to show the output of the subprocess in real time.

Value

The R process, a processx::process object.

See also

Other asciicast functions: asciicast-package, read_cast(), record(), write_json()

Examples

# Use the same R process to record multiple casts
process <- asciicast_start_process()
script1 <- "a <- runif(10)\n"
script2 <- "a\n"
cast1 <- record(textConnection(script1), process = process)
cast2 <- record(textConnection(script2), process = process)
cast1
#> <asciicast>
#> <config>
#>   "version": 2,
#>   "command": "R -q",
#>   "timestamp": 1705870413,
#>   "env": {
#>     "TERM": "xterm-256color",
#>     "SHELL": "/bin/zsh"
#>   },
#>   "height": 24,
#>   "rows": 24,
#>   "width": 80,
#>   "cols": 80
#> 
#> <frames>
#> # A tibble: 24 × 3
#>      time type  data                
#>     <dbl> <chr> <chr>               
#>  1 0      rlib  "type: prompt"      
#>  2 0      o     "> "                
#>  3 0      i     "a <- runif(10)\r\n"
#>  4 0      rlib  "type: input"       
#>  5 0.0444 o     "a"                 
#>  6 0.118  o     " "                 
#>  7 0.158  o     "<"                 
#>  8 0.217  o     "-"                 
#>  9 0.278  o     " "                 
#> 10 0.313  o     "r"                 
#> # ℹ 14 more rows
cast2
#> <asciicast>
#> <config>
#>   "version": 2,
#>   "command": "R -q",
#>   "timestamp": 1705870413,
#>   "env": {
#>     "TERM": "xterm-256color",
#>     "SHELL": "/bin/zsh"
#>   },
#>   "height": 24,
#>   "rows": 24,
#>   "width": 80,
#>   "cols": 80
#> 
#> <frames>
#> # A tibble: 39 × 3
#>      time type  data          
#>     <dbl> <chr> <chr>         
#>  1 0      rlib  "type: prompt"
#>  2 0      o     "> "          
#>  3 0      i     "a\r\n"       
#>  4 0      rlib  "type: input" 
#>  5 0.0400 o     "a"           
#>  6 0.0400 o     "\r\n"        
#>  7 0.0401 rlib  "busy: 1"     
#>  8 0.0401 rlib  "type: stdout"
#>  9 0.0401 o     " [1]"        
#> 10 0.0401 rlib  "type: stdout"
#> # ℹ 29 more rows