CommandHistory class

Persistent, per-key command history backed by a plain-text file.

Each key (typically <user>@<node>) maps to its own file under <home>/.omnyshell/history/<key>.history, so connecting to different nodes or as different principals never mixes histories. The home directory resolves from OMNYSHELL_HOME, then HOME, then USERPROFILE — the same convention used by the credential store.

Constructors

CommandHistory.inMemory({List<String>? entries, int maxEntries = 1000})
An in-memory history with no backing file (used by tests).
factory

Properties

entries List<String>
The entries, oldest first. The returned list is a copy.
no setter
hashCode int
The hash code for this object.
no setterinherited
maxEntries int
Upper bound on retained entries; oldest are dropped first.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(String entry) Future<void>
Records entry, skipping blank lines and consecutive duplicates, then persists the (trimmed-to-cap) history. IO failures are swallowed so the interactive session is never interrupted by a disk error.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

load({required String key, String? home, int maxEntries = 1000}) Future<CommandHistory>
Loads the history for key, returning an empty history when no file exists yet. Pass home to override the base directory (used by tests).
migrate({required String fromKey, required String toKey, String? home, int maxEntries = 1000}) Future<void>
Copies the history recorded under fromKey into toKey, placing the migrated entries before any already present under toKey (consecutive duplicates are collapsed at the splice boundary). The fromKey file is left intact as a backup. A no-op when the source is missing or empty.
sanitizeKey(String key) String
Maps an arbitrary key to a safe, stable filename component.