Replay
Replay your REPL instructions something like this:
Introduction
Let’s assume you have to record your screen to explain something about Julia topics e.g. how to use REPL, how to use your great package in Julia REPL etc… You are supposed to input your source code by hand line by line. Imagine that you type the following lines.
julia> 2+2
julia> print("")
julia> display([1])
julia> display([1 2; 3 4])
julia> @time 1+1
julia> using Pkg; Pkg.activate(".")
pkg> add Example
pkg> rm Example
pkg> st
Should we type them one by one using your fingers? We are too lazy to do.
Don't worry! Our package Replay.jl
saves your life!
Usage
$ git clone https://github.com/AtelierArith/Replay.jl.git
$ cd Replay.jl
$ cat ./examples/readme/app.jl
using Replay
repl_script = """
2+2
print("")
display([1])
display([1 2; 3 4])
@time 1+1
using Pkg; Pkg.activate(".")
]add Example
rm Example
st
$CTRL_C
"""
replay(repl_script, stdout, julia_project=@__DIR__, use_ghostwriter=true, cmd="--color=yes")
$ julia --project=@. -e 'using Pkg; Pkg.instantiate()'
$ julia --project=@. ./examples/readme/app.jl
$ # Below is optional
$ asciinema rec result.cast --command "julia --project=@. ./examples/readme/app.jl"
$ asciinema play result.cast
You can redirect the output of the program into a file:
$ julia --project=@. ./examples/helloworld/app.jl > output.txt
$ cat output.txt
Tips: you can set replay(instructions; cmd="--color=no")
as necessary.
$ julia examples/disable_color/app.jl > output.txt
$ cat output.txt
asciinema
Record instructions using- asciinema is a free and open source solution for recording terminal sessions and sharing them on the web. It can be used in combination with Replay.jl with the following commands:
$ pip3 install asciinema # install `asciinema`
$ asciinema rec output.cast --command "julia examples/helloworld/app.jl"
$ asciinema play output.cast
See This issue to learn more.
Examples
- We provide several examples to testout our Package.
$ tree examples
examples
├── disable_color
│ └── app.jl
├── helloworld
│ └── app.jl
├── imageinterminal
│ ├── Project.toml
│ └── app.jl
├── iris
│ ├── Project.toml
│ └── app.jl
├── ohmyrepl
│ ├── Project.toml
│ └── app.jl
├── plots_with_sixel
│ ├── Project.toml
│ └── app.jl
├── quietmode
│ └── app.jl
├── readme
│ ├── Project.toml
│ └── app.jl
├── sixel
│ ├── Project.toml
│ └── app.jl
├── unicodefun
│ ├── Project.toml
│ └── app.jl
├── unicodeplots
│ ├── Project.toml
│ └── app.jl
├── unicodeplots_animated
│ ├── Project.toml
│ └── app.jl
└── use_ghostwriter
└── app.jl
Breaking Change
- The internal logic of the program has been changed to stabilize its operation. As a side effect, we had to make some destructive changes to the API.
- Note that
color
kwarg ofreplay
is removed sincev0.4.x
. Usecmd="--color=yes"
orcmd="--color=no"
instead.
Restriction
- Replay.jl does not work on Windows. Please use WSL2 instead.
Acknowledgements
Replay.jl is based on
The idea of how to replay julia session comes from
@hyrodium san provided an excellent logo for our package.
- See this PR #7.