mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-20 09:58:00 +02:00
feat: allow ignoring failed commands (#1957)
* feat: allow ignoring failed commands * cleanup
This commit is contained in:
parent
cb19925011
commit
2fba4aae93
@ -370,6 +370,7 @@ pub struct Settings {
|
|||||||
pub scroll_context_lines: usize,
|
pub scroll_context_lines: usize,
|
||||||
pub history_format: String,
|
pub history_format: String,
|
||||||
pub prefers_reduced_motion: bool,
|
pub prefers_reduced_motion: bool,
|
||||||
|
pub store_failed: bool,
|
||||||
|
|
||||||
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
#[serde(with = "serde_regex", default = "RegexSet::empty")]
|
||||||
pub history_filter: RegexSet,
|
pub history_filter: RegexSet,
|
||||||
@ -645,6 +646,7 @@ impl Settings {
|
|||||||
.set_default("keymap_mode_shell", "auto")?
|
.set_default("keymap_mode_shell", "auto")?
|
||||||
.set_default("keymap_cursor", HashMap::<String, String>::new())?
|
.set_default("keymap_cursor", HashMap::<String, String>::new())?
|
||||||
.set_default("smart_sort", false)?
|
.set_default("smart_sort", false)?
|
||||||
|
.set_default("store_failed", true)?
|
||||||
.set_default(
|
.set_default(
|
||||||
"prefers_reduced_motion",
|
"prefers_reduced_motion",
|
||||||
std::env::var("NO_MOTION")
|
std::env::var("NO_MOTION")
|
||||||
|
@ -348,6 +348,15 @@ impl Cmd {
|
|||||||
return Ok(());
|
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.exit = exit;
|
||||||
h.duration = match duration {
|
h.duration = match duration {
|
||||||
Some(value) => i64::try_from(value).context("command took over 292 years")?,
|
Some(value) => i64::try_from(value).context("command took over 292 years")?,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user