diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-03-08 20:17:31 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-03-08 20:17:31 -0500 |
commit | 4151ab7aab939a12721a0f4207c87b5c09ace339 (patch) | |
tree | db2f9935a3369aa18ebb6076188fda34fbd92bd8 /src/shell/history/mod.rs | |
parent | 0688cd6653e769846a4271ac2c251a7d96249396 (diff) | |
download | nbsh-master.tar.gz nbsh-master.zip |
Diffstat (limited to 'src/shell/history/mod.rs')
-rw-r--r-- | src/shell/history/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs index ad6ca44..91149c1 100644 --- a/src/shell/history/mod.rs +++ b/src/shell/history/mod.rs @@ -123,6 +123,27 @@ impl History { } } + pub async fn save(&self) { + // TODO: we'll probably want some amount of flock or something here + let mut fh = tokio::fs::OpenOptions::new() + .append(true) + .open(crate::dirs::history_file()) + .await + .unwrap(); + for entry in &self.entries { + fh.write_all( + format!( + ": {}:0;{}\n", + entry.start_time().unix_timestamp(), + entry.cmd() + ) + .as_bytes(), + ) + .await + .unwrap(); + } + } + fn visible( &self, repl_lines: usize, |