Crates.io | mimic |
lib.rs | mimic |
version | 0.1.6 |
created_at | 2025-08-20 13:27:56.604341+00 |
updated_at | 2025-08-22 10:00:03.083161+00 |
description | A text / code playback tool |
homepage | https://github.com/togglebyte/mimic |
repository | https://github.com/togglebyte/mimic |
max_upload_size | |
id | 1803402 |
size | 228,381 |
Script and playback of text with syntax highlighting.
Create a example.echo
file and add the following code:
// example.echo
load "src/main.rs" as main
extension "rs"
speed 20
jitter 20
line_pause 300
type main
Then run it with:
$ mimic example.echo
To add syntax highlighting for a language currently not included:
Copy the directory into your equivalent of ~/.config/mimic/syntax/<lang>
.
Mimic was made with Anathema and the templates are installed by default the first time the program is run.
The templates are located in the following directories depending on your platform:
~/.config/mimic/templates
C:\Users\<user>\AppData\Roaming\mimic\templates
/Users/<user>/Library/Application Support/mimic/templates
To add support for TOML
copy the TOML
directory from this repository into ~/.config/mimic/syntax/TOML
.
Markers are used as jump-to points in the code. A marker represents a line in the code.
Given the following code:
fn main() {
// @marker
println!("hello world");
}
A goto marker
instruction would place the cursor at the beginning of the
println
macro:
fn main() {
-> println!("hello world");
}
Load a file into memory
Syntax: load <filepath> as <ident>
Delete selected region and place the cursor at the start of the region.
Syntax: delete
Move the cursor to a marker if a marker named is given, or to a position
relative to the current cursor. The position is given as row
and col
offset.
This means goto 0 0
keeps the cursor in its current position,
where as goto 1 0
moves the cursor down one row but keeps it on the same column.
Note that goto <marker>
will go to the line where the marker was inserted,
and first column, regardless of what the column is before the goto
.
Syntax: goto <marker>|<row> <col>
Insert either a string or content from memory.
Syntax: insert <marker>|<string>
or insert <string>
Select the text from the current cursor position given a width and a height.
Syntax: select <width> <height>
Type out the given text in the editor.
Syntax: type <ident>|<string>
Type the given text in the editor, unlike the type
command this will insert a
newline character and move the cursor into the new empty line and start the
typing.
This has a more natural appearance when inserting new lines into existing code.
Syntax: typenl <ident>|<string>
or optionally to remove the final trailing newline character:
Syntax: typenl <ident>|<string> nonl
Wait N seconds before loading the next command.
sleep
is an alias for wait
Syntax: wait <seconds>
This value is given in number of instructions per second.
Syntax: speed <integer>
Default: 20
Set the speed for which to wait after each newline char is typed
Syntax: line_pause|linepause <milliseconds>
Default: 0
Selects, deletes and replaces the text.
Syntax: replace <string> <ident>|<string>
Show / hide line numbers
Syntax: numbers <true|false>
Default: false
Clear the screen
Syntax: clear
Set the file extension for the syntax highlighter
Syntax: extension "rs"
Default: "txt"
Pad the frame time with some jitter, making for a more natural appearance of typing.
Syntax: jitter 25
Default: 20
Set the theme.
To see a list of themes run mimic --themes
.
Syntax: theme <string>
Load a directory with audio files for typing sounds.
Each key will be mapped to an audio file with the same name.
E.g a
-> a.mp3
, _
-> _.mp3
If no filename is found it will fallback to default.mp3
.
If default.mp3
is missing an error will be raised.
Syntax: audio <filepath>
Show a popup message
Syntax: popup <string>|<ident>
Close a popup message
Syntax: close_popup|closepopup
Move the cursor to a specific word on the same line as the cursor is on. A second argument decides the nth instance to find.
Syntax: find <string> <int>?
Same as find
but places the cursor at the end of the result instead of the
start.
Syntax: finde <string> <int>?
Write the buffer to disk. This will fail if the file already exists.
Syntax: write <path>
.
Simulate typing a command to the command line in the editor
Syntax: command <string>|<ident>
Clear the command line after N milliseconds
Syntax: command_clear_timeout <milliseconds>
Set a context value in the template
Syntax: set <ident> <string>|<bool>|<int>
Note This instruction is only relevant in the context of the template.
This can be accessed in the template as state.ctx.<ident>
.
For more information on how this works see Anathema.
Include another echo file.
This file will have its own context (meaning given load "x" as x
x
is only relevant in the included echo file).
Syntax: include "other.echo"