pub struct FileHistory { /* private fields */ }Expand description
Reads history from shell history files on disk.
Supports:
- zsh: ~/.zsh_history (extended format with timestamps)
- bash: ~/.bash_history (plain text, one command per line)
- fish: ~/.local/share/fish/fish_history (custom format)
Implementations§
Source§impl FileHistory
impl FileHistory
pub fn new(shell: Shell) -> Self
pub fn with_path(shell: Shell, path: PathBuf) -> Self
pub fn shell(&self) -> Shell
Sourcepub fn entries(&self) -> &[HistoryEntry]
pub fn entries(&self) -> &[HistoryEntry]
Get all history entries (for context in other tiers like CloudTier)
Sourcepub fn reload_if_changed(&mut self)
pub fn reload_if_changed(&mut self)
Check if history file changed since last load, reload if so. Returns silently on any error (file locked, inaccessible, etc.) — uses cached results.
Note: There is an inherent TOCTOU race between stat and read. This is acceptable because worst case we read newer data but record older metadata, which self-corrects on the next request.
Sourcepub fn command_names(&self) -> Vec<&str>
pub fn command_names(&self) -> Vec<&str>
Return unique first-token command names from history, in frequency order. Used for fuzzy matching when prefix search fails.
Trait Implementations§
Source§impl ShellHistory for FileHistory
impl ShellHistory for FileHistory
Auto Trait Implementations§
impl Freeze for FileHistory
impl RefUnwindSafe for FileHistory
impl Send for FileHistory
impl Sync for FileHistory
impl Unpin for FileHistory
impl UnsafeUnpin for FileHistory
impl UnwindSafe for FileHistory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more