Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): add prune filters for age and length #2494

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imsakg
Copy link

@imsakg imsakg commented Dec 26, 2024

  • Introduce options to prune history by minimum age and maximum length.
  • Default dry_run to true and allow optional specification.
  • Improve command filtering for efficient pruning.

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

- Introduce options to prune history by minimum age and maximum length.
- Default `dry_run` to true and allow optional specification.
- Improve command filtering for efficient pruning.
@imsakg
Copy link
Author

imsakg commented Dec 26, 2024

Example usages:

  • atuin history prune --max-length 200
  • atuin history prune --min-age 86400 --dry-run false

@tessus
Copy link
Contributor

tessus commented Dec 29, 2024

I don't really understand the use-case for this. history prune only deletes history that matches the history_filter.

The use-case for pruning was to remove entries from the history after one changes the history_filter. So why would you want to not record command x, but keep all commands x not older than N seconds?

Don't get me wrong, I am not against your PR (and I don't make any decisions for this project anyway), I am just saying that I do not understand your use-case.

@imsakg
Copy link
Author

imsakg commented Jan 3, 2025

Hey @tessus,

Certainly, I did not get it wrong. Let me clarify my use case and the purpose of this pull request.

Consider a scenario where you are executing a command and frequently changing flags until you identify the correct one. Once you have determined the appropriate flag, you may not wish to retain the other executed commands in your Atuin database, as they contribute to unnecessary bloat.

For example:

  1. my_command -x my_file
  2. my_command -x -y my_file
  3. my_command -x -y -z my_file
  4. my_command -a my_file <-- This is the correct command.

Additionally, there is another use case to consider. Suppose you are executing commands that you intend to use only once. Such commands will also be stored in your Atuin database, and it is likely that you do not wish to keep them.

For instance:

DB_CONNECTION_STRING=aws-some-db-service-some-weird-url-geolocating-tag-bla-bla-bla my_program_that_connecting_to_db query "Hello World"

This pull request allows you to remove those unnecessary commands based on their length or age.

@tessus
Copy link
Contributor

tessus commented Jan 3, 2025

Interesting, I understand. Mostly, I guess.

I would have pruned all and then used the "correct" version of the command once (which is either in my clipboard or I saved it in a temp file)
However, if my_command is in the history_filter, it wouldn't be recorded either way, so still a bit confused there. This workflow makes more sense for atuin search --delete operations than pruning, but maybe I'm still missing something.

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.

2 participants