Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/shell/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::Path;
use std::path::PathBuf;

use anyhow::Context;
Expand Down Expand Up @@ -42,6 +43,13 @@ async fn interactive() -> anyhow::Result<()> {
let mut state = init_state();

let home = dirs::home_dir().context("Couldn't get home directory")?;
let history_file: PathBuf = [home.as_path(), Path::new(".shell_history")]
.iter()
.collect();
if Path::new(history_file.as_path()).exists() {
rl.load_history(history_file.as_path())
.context("Failed to read the command history")?;
}

let mut _prev_exit_code = 0;
loop {
Expand Down Expand Up @@ -117,6 +125,8 @@ async fn interactive() -> anyhow::Result<()> {
}
}
}
rl.save_history(history_file.as_path())
.context("Failed to write the command history")?;

Ok(())
}
Expand Down