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.

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. 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 (exclusive). Use -1 for $upto to not set an upper bound.

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.

NOTE: This command only deletes the entry from the persistent store. When deleting an entry that was added in the current session, the deletion will not take effect for the current session, since the entry still exists in the in-memory per-session history.

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:del-shared-var

store:del-shared-var $name

Deletes the shared variable with the given name.

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.

store:set-shared-var

store:set-shared-var $name $value

Sets the value of the shared variable with the given name, creating it if it doesn’t exist. The value must be a string.

store:shared-var

store:shared-var $name

Outputs the value of the shared variable with the given name. Throws an error if the shared variable doesn’t exist.