How to remove failed command from the history?

Hi,

How can I filter out failed shell commands from the history using?

And thank you for the great product.

Hello and welcome. As in removing all failed commands from the history? Ctrl+a d as a shortcut from the main search window to remove the currently selected command, or using the TUI inspector with Ctrl+o Ctrl+d. Or from the command line using atuin search <search query with additonal flags for filtering> --delete.

So to filter out all failed shell commands with the exit code <exit number>, one could write something like

atuin search --exit=<exit number> <additional flags and query for filtering> --delete

Run first without the --delete to see the result first, then run again with --delete to remove all matching results. If truly removing all such cases is what you want, you can create a script with a for loop over all exit codes different from 0.

If you need to filter them out only temporarily, you could do something like

atuin search --exclude-exit=<exit number> <query and additional tags to filter the history further>

If you want to take this query and show the results in the interactive Atuin search window, that is not possible at the moment, if I am not mistaken. That is, atuin search --iteractive will take you to the interactive fuzzy search window, but it will ignore the other flags except for the query. Actually, this could a feature request, thinking about it :thinking: