summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-04-18 08:18:15 +0100
committerGitHub <noreply@github.com>2024-04-18 08:18:15 +0100
commit2fba4aae933c17f0024110dd9ec4a57d748cf867 (patch)
treef59aaf3e4305921c13b110429153e4f711185244
parentcb19925011d889c513e1bbedc446e399597e38a0 (diff)
feat: allow ignoring failed commands (#1957)
* feat: allow ignoring failed commands * cleanup
-rw-r--r--atuin-client/src/settings.rs2
-rw-r--r--atuin/src/command/client/history.rs9
2 files changed, 11 insertions, 0 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index 541cb4d9..035af321 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -370,6 +370,7 @@ pub struct Settings {
pub scroll_context_lines: usize,
pub history_format: String,
pub prefers_reduced_motion: bool,
+ pub store_failed: bool,
#[serde(with = "serde_regex", default = "RegexSet::empty")]
pub history_filter: RegexSet,
@@ -645,6 +646,7 @@ impl Settings {
.set_default("keymap_mode_shell", "auto")?
.set_default("keymap_cursor", HashMap::<String, String>::new())?
.set_default("smart_sort", false)?
+ .set_default("store_failed", true)?
.set_default(
"prefers_reduced_motion",
std::env::var("NO_MOTION")
diff --git a/atuin/src/command/client/history.rs b/atuin/src/command/client/history.rs
index b9e54b50..e6774816 100644
--- a/atuin/src/command/client/history.rs
+++ b/atuin/src/command/client/history.rs
@@ -348,6 +348,15 @@ impl Cmd {
return Ok(());
}
+ if !settings.store_failed && h.exit != 0 {
+ debug!("history has non-zero exit code, and store_failed is false");
+
+ // the history has already been inserted half complete. remove it
+ db.delete(h).await?;
+
+ return Ok(());
+ }
+
h.exit = exit;
h.duration = match duration {
Some(value) => i64::try_from(value).context("command took over 292 years")?,