Feature request: Search context around history entry

Not sure if this is already possible, but I haven’t found a way to do it yet:

There are a lot of times when I’m looking to find a collection of commands I’ve issued around the same time. I don’t have good enough shell hygiene to compose all of my steps into one execution, so usually they’re spread across multiple history entries.

It would be baller to be able to search for something like kubectl <something> and then be able to expand context around that entry like grep -A # -B # … Or, at least be able to dive into that point in history w/o losing where it’s at.

2 Likes

atuin history list | less

I would also love this. I’ve found three aliases in the meantime which could be helpful:

atuin history list | rg (or grep) which is quick and lets me add context flags at the end, but loses interactivity

atuin history list | fzf --track which is quick and interactive, and the track flag keeps the highlighted line after you remove the search term

atuin history list | lnav (lnav) which lets me interactively search or filter and then disable filters to see full context, lets me filter by search term, directory, and host independently, can define a fancy colored format to match your history list format to make it more readable, and you can use G and g to move to the top and bottom if you need. It’s a bit overkill for just finding a recent command, but if you’re really planning to dig through your history it works great.

1 Like

Yes! Just discovered this need today.

Here’s what I did:

  1. ^r src/Makefile to find the last time I custom-built vim
  2. ^o to inspect and copy date 2023-11-09
  3. Esc to shell prompt
  4. atuin search --after 2023-11-08 --before 2023-11-10 | less
  5. / src/Makefile to find the same command from step 1
  6. Navigate up and down from there to refresh my memory on the process

Here’s what I’d love to do:

  1. ^r src/Makefile to find the last time I custom-built vim
  2. [new hotkey] to browse context—effectively, keep the currently highlighted entry, maybe vertically center it, but clear the search/filter.
  3. Navigate up and down from there to refresh my memory on the process
1 Like