Hacker News new | ask | show | jobs
by threecheese 266 days ago
How can you use grep to search the scrollback/screen buffer?
3 comments

I don't want to presume your use case, but Ghostty has a command for dumping the buffer to a file, which I use for processing output "too late" to use grep.

keybind = ctrl+alt+shift+o=write_scrollback_file:open

Try a pager instead. Batcat is more feature rich but there's always the good old less (and more) command. Both work great with grep. I do things like the following multiple times a day

  $ cat foo.log | less
  $ cat foo.log | $PAGER
  $ cat foo.log | grep 09-23-2025 | less
Side note / pro tip: on a new line in the terminal press control-x control-e. If you're in zsh you need to edit your config but this will work out of the box for bash.
You can leave the cat at home.

  less foo.log
  grep 09-25-2025 foo.log | less
but he will feel lonely if he doesn't participate :(
Ghostty has a write_scrollback_file action you can use to write the scrollback to a temporary file. I have this set to cmd+shift+f, so I simply

less [cmd+shift+f] [enter]

You can use grep similarly.