I wish this worked without prefixing the commands with "once". Especially if I ran a command with verbose output and afterwards decided I wanted to grep something from it. Terminals have the output in their scrollback buffer and maybe it's just a matter of writing an "output" command that lets me run:

    $ cmake ..
    $ output | grep "libssl version"

Maybe the shell or the terminal itself could do that.

Some terminals already allow you to search they buffer after commands have executed, so maybe it’s a small step away from being able to use that as a cache.

You could probably achieve something like that using Fish shell and their fish_preexec and fish_postexec event hooks.

Edit: Nope, looks like you can't. You only get the invoked command and no output.

Could you use preexec + tee?

Unfortunately not, the preexec event happens asynchronously from the actual execution of the command. You can't manipulate or otherwise log the output of what's run, all you get is a copy of the command text.

I run bash from inside vim and nvim. At anytime I can drop into vim and use the entire scrolled history as a buffer.