From b331eef4df77a926f721439eda0fe63ef0ff6191 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 4 Oct 2024 22:58:00 +0800 Subject: [PATCH] feat: option to include duplicate commands when printing history commands --- crates/atuin-client/src/database.rs | 5 ++++- crates/atuin/src/command/client/search.rs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs index 4f126030f63..ac9feb0802c 100644 --- a/crates/atuin-client/src/database.rs +++ b/crates/atuin-client/src/database.rs @@ -51,6 +51,7 @@ pub struct OptFilters { pub limit: Option, pub offset: Option, pub reverse: bool, + pub include_duplicates: bool, } pub fn current_context() -> Context { @@ -403,7 +404,9 @@ impl Database for Sqlite { ) -> Result> { let mut sql = SqlBuilder::select_from("history"); - sql.group_by("command").having("max(timestamp)"); + if !filter_options.include_duplicates { + sql.group_by("command").having("max(timestamp)"); + } if let Some(limit) = filter_options.limit { sql.limit(limit); diff --git a/crates/atuin/src/command/client/search.rs b/crates/atuin/src/command/client/search.rs index 12e73458ffd..e64600a5cc3 100644 --- a/crates/atuin/src/command/client/search.rs +++ b/crates/atuin/src/command/client/search.rs @@ -119,6 +119,10 @@ pub struct Cmd { /// Set the maximum number of lines Atuin's interface should take up. #[arg(long = "inline-height")] inline_height: Option, + + /// Include duplicate commands in the output (non-interactive only) + #[arg(long)] + include_duplicates: bool, } impl Cmd { @@ -215,6 +219,7 @@ impl Cmd { limit: self.limit, offset: self.offset, reverse: self.reverse, + include_duplicates: self.include_duplicates, }; let mut entries =