←back to thread

538 points todsacerdoti | 7 comments | | HN request time: 1.258s | source | bottom
1. b0a04gl ◴[] No.44358586[source]
terminal scrollback is the only UI we don't treat as queryable state. op's setup shows how much context we're missing away a lot of rg output, file paths, stack traces, build logs they're all already right there in cluttered state.

if shells exposed a scrollback api with line refs and structural tagging, we could annotate paths, link to buffers, diff last two runs, all without re executing anything. that would cut through half the indirection in current workflows. tmux's regex jump is a hack but it hints at a deeper model. scrollback should be its own memory layer

replies(2): >>44358596 #>>44358757 #
2. jynelson ◴[] No.44358596[source]
yes!! one of the things i really want from a terminal is structured metadata, it allows you to build so much on top. right now anything remotely close requires parsing a bunch of ansi escapes.
replies(2): >>44358629 #>>44360949 #
3. Analemma_ ◴[] No.44358629[source]
PowerShell got so close to doing this, and then they fumbled it right at the finish line by having terminal objects be binary data instead of structured objects in some kind of serialized format. PowerShell is honestly awesome for a bunch of reasons and getting to query pipe objects instead of parsing them is great, but the binary blobs hold it back from being perfect.

Several attempts have been made to do similar things in Unix, but there's a massive ecosystem problem: four decades of classic tooling has to be totally rewritten to get this kind of support. I don't see it happening without some kind of industry champion who can throw their weight around to force it on people.

replies(1): >>44358721 #
4. jynelson ◴[] No.44358721{3}[source]
i have ideas about how to strangler-pattern this so that it doesn't require a "flag day" where everyone switches over at once. i have about 15 paragraphs of this written up locally i need to turn into a blog post ^^
replies(1): >>44359401 #
5. msgodel ◴[] No.44358757[source]
That's the tty or the thing on the other end of the pty (ie your VTE like Xterm) which would have to do that. The shell has no access to any of it.

There is an xterm command for writing the scrollback buffer to a file so in theory if you wanted a hack to enable it today you could use that + grep (or even trigger it with something xdotool if you wanted to automate it.)

6. Analemma_ ◴[] No.44359401{4}[source]
I would love a new standard stream for structured output alongside stdout and stderr. That seems like the lowest-friction way to get tooling migrated: programs could opt-in if they wanted but nothing would break if they didn't, and then once you had sufficient buy-in you could make a new shell that defaulted to piping this new stream and fall back to stdout if there was no data in the new one. But it would still need a lot of coordination to make it happen, since AIUI you would need to change libc and every other C runtime to pass this new stream fd to every program, and that would rile people up.
7. abnercoimbre ◴[] No.44360949[source]
Interesting. You might (or might not, I'm not really sure!) become interested by Terminal Click [0]

If you want a comprehensive demo with even more features, I have one in this community video [1]

Anyone can email me if they're game: abner at terminal dot click

[0] https://terminal.click/posts/2025/04/the-wizard-and-his-shel...

[1] https://vimeo.com/1091637660 (6-minute mark)