Skip to content

Support passing --limit to atuin search --delete#3184

Open
keysmashes wants to merge 2 commits intoatuinsh:mainfrom
keysmashes:push-smtzoouvrltn
Open

Support passing --limit to atuin search --delete#3184
keysmashes wants to merge 2 commits intoatuinsh:mainfrom
keysmashes:push-smtzoouvrltn

Conversation

@keysmashes
Copy link
Copy Markdown

Fixes #3177.

As pointed out previously (#1436), there are two plausible ways this could be expected to work:

  1. The search is executed across (deduplicated) commands, then every usage of the first N commands in the result is deleted.
  2. The search is executed across history entries, then the first N history entries in the result are deleted (and other usages of the same command are left intact).

With option 1, it's nonsensical to pass --include-duplicates: if the results for atuin search --include-duplicates --limit 3 were "foo", "bar", and "foo", then only two commands would actually be deleted. (If the command "baz" was executed before those three, then without --include-duplicates it would have been included in the results – so passing that flag would actually have reduced the number of commands being deleted!)

With option 2, it's easier to reason about what's happening: every deletion already acts as if --include-duplicates was passed, so deletions always operate on individual history entries (not aggregated commands), therefore we don't have to worry about what would happen if --include-duplicates was/wasn't passed. To make it obvious that this is how --limit works, we require that --include-duplicates is explicitly passed whenever using --delete together with --limit.

Therefore this PR implements option 2.

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 13, 2026

Greptile Overview

Greptile Summary

Implements support for using --limit with atuin search --delete by requiring --include-duplicates to ensure consistent behavior between search preview and deletion. Refactors deletion from a loop-based approach to a single-pass operation.

Key changes:

  • Removed blanket prohibition on --limit with --delete
  • Modified empty query validation to allow --delete --limit without a query
  • Added explicit requirement for --include-duplicates when combining --limit and --delete to avoid confusion about which entries get deleted
  • Simplified deletion logic from repeated search-delete loops to a single search followed by batch deletion
  • Automatically forces include_duplicates = true during the deletion search to preserve existing behavior (deleting all instances of matched commands)

Important Files Changed

Filename Overview
crates/atuin/src/command/client/search.rs Enables --limit with --delete by requiring --include-duplicates and switching from loop-based to single-pass deletion logic

Last reviewed commit: f9a0d01

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

keysmashes and others added 2 commits February 13, 2026 14:14
As pointed out previously, there are two plausible ways this could be
expected to work:

1. The search is executed across (deduplicated) commands, then every
   usage of the first N commands in the result is deleted.
2. The search is executed across history entries, then the first N
   history entries in the result are deleted (and other usages of the
   same command are left intact).

With option 1, it's nonsensical to pass `--include-duplicates`: if the
results for `atuin search --include-duplicates --limit 3` were "foo",
"bar", and "foo", then only two commands would actually be deleted. (If
the command "baz" was executed before those three, then without
`--include-duplicates` it would have been included in the results – so
passing that flag would actually have *reduced* the number of commands
being deleted!)

With option 2, it's easier to reason about what's happening: every
deletion already acts as if `--include-duplicates` was passed, so
deletions always operate on individual history entries (not aggregated
commands), therefore we don't have to worry about what would happen if
`--include-duplicates` was/wasn't passed. To make it obvious that this
is how `--limit` works, we require that `--include-duplicates` is
*explicitly* passed whenever using `--delete` together with `--limit`.
@ellie ellie force-pushed the push-smtzoouvrltn branch from f9a0d01 to f441748 Compare February 13, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: searching (deleting) by exact string match

2 participants