I have an unlimited .zsh_history which is currently at 10k lines. I often want to see all commands from history that have a certain string, for example curl. If I do history | grep curl it takes a long time to finish. If I do grep curl ~/.zsh_history it is much faster, but the formatting is broken (timestamps aren't parsed into dates, delimiters are left as symbols).
Is there a way around the slowness of piping history to grep? I see people recommending Ctrl+R but that is clearly not the same thing - grep produces a list of commands while Ctrl+R shows them one at a time. Also piping to grep allows chaining multiple grep filters, while the same thing is not possible with Ctrl+R.
historycommand is doing a lot of processing. So some technique that does that conversion incrementally one-time, or in background, is going to be helpful.historywithoutgrep(althoughgrepproves that the problem is not only due to the large number of lines printed to stdout)