nb-nik.org

rep

Rep is a simple command line spaced repetition system.

Rep is similar to other spaced repetition programs like Anki except it’s designed to be easily integrated into your existing text editor / terminal workflow.

Build

Rep is written in Go. To build it, you need make and Go (version 1.24 or later).

To build the executable and install it to ~/.local/bin/, type:

git clone https://git.sr.ht/~reticular-flux/rep
cd rep
make install

To build the executable in the current directory, instead of make install, just type make.

Test

To run the tests, run:

make test

Configuration

The configuration file uses the YAML format. It should be located at $XDG_CONFIG_HOME/rep/config.yaml.

The only mandatory field in the configuration is the location of the database. The path should the full path (~ or environment variables aren’t allowed). Example:

database: /home/nik/.local/share/rep/flashcards.db

The text editor that gets opened is specified by the editor field. If this field is not set, then rep will look for the EDITOR environment variable.

Usage

Initialisation

First, you need to initialise a database (the location of which is specified in the config file):

rep init

If a file at the path specified in the configuration database already exists, this command will cause an error (and the file won’t be overwritten).

Adding items

Items are added using the add command. add expects a single argument, so put the text between single quotes. Single quotes (as opposed to double) will also likely be necessary to stop the field syntax being interpreted by the shell.

An item contains one or more fields. The text between the field delimeters is hidden when reviewing a prompt.

Fields can either be ‘implicit’ or ’explicit’:

Implicit and explicit fields can be used within the same item. Implicit fields are numbered consecutively from 1 or from the previous explicit field number.

Fields are regex patterns. The regex syntax is described at .

Examples:

# Implicit field
rep add 'Which command is used to add items? <[add]>'

# Explicit field
rep add 'Which command is used to add items? <[1:add]>'

# Combining the two
rep add 'The <[1:capital]> of France is <[Paris]>.'

Reviewing items

Prompts are reviewed using the next command. This command will open a prompt in your text editor of choice. The releveant field will be hidden (’!!’ will be shown between the delimeters instead). You can replace the mask with your attempt, then save the file and close the editor. If your attempt matches the answer, the prompt will be given a pass grade. Else, you can use the grade command to grade the prompt manually.

Prompts can also be reviewed interactively by adding the --interactive flag with next. After each prompt, you can either carry on (by pressing ‘c’), quit (by pressing ‘q’), or modify the prompt you just answered (’m’).

Grading an item

Prompts are graded using the grade command. The possible grades are p (pass) or f (fail).

# If you answered correctly.
rep grade pass

# If you got the answer wrong (using the single letter alternatives)
rep g f

Deleting an item

Items are deleted using the `delete’ command. Either give the ID of the item you want to delete, or the most recently reviewed item will get deleted.

# Delete item 1234
rep delete 1234

# Delete the most recently reviewed item
rep delete

Searching

You can do a full text search through all the items using the search command:

rep search needle