store: API for the Elvish persistent data store

Table of content

Introduction

The store: module provides access to Elvish’s persistent data store. It is only available in interactive mode now.

Sequence numbers are not persistent. They change whenever history entries are removed. If you reload the history via edit:history:fast-forward the sequence numbers can change.

Sequence numbers start at one. A negative sequence is relative to the end of the command history. For example, -1 is the most recent command, -2 the second most recent command, etc. Commands that take a sequence number range are inclusive of the starting and ending sequence number and either value can be positive (relative to the beginning) or negative (relative to the end).

Functions

store:add-cmd

store:add-cmd $text

Adds an entry to the command history with the given content. Outputs its sequence number.

store:add-dir

store:add-dir $path

Adds a path to the directory history; increasing its score if it is already present in the history. This will also cause the scores of all other directories to decrease.

store:cmd

store:cmd $seq

Outputs the content of the command history entry with the given sequence number.

store:cmds

store:cmds $from $upto

Outputs all command history entries with sequence numbers between $from (inclusive) and $upto (inclusive). Use -1 for $upto to refer to the last entry in the history.

Each entry is represented by a pseudo-map with fields text and seq.

store:del-cmd

store:del-cmd $seq

Deletes the command history entry with the given sequence number and all other history entries with the same command text. This will result in sequence numbers changing.

store:del-dir

store:del-dir $path

Deletes a path from the directory history. This has no impact on the scores of other directories.

store:dirs

store:dirs

Outputs all directory history entries, in decreasing order of score.

Each entry is represented by a pseudo-map with fields path and score.

store:next-cmd-seq

store:next-cmd-seq

Outputs the sequence number that will be used for the next entry of the command history.