frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Ask HN: How to Extract Shell Commands from Raw PTY Sessions? (Rewindtty)

2•debba•2h ago
Project URL: https://github.com/debba/rewindtty

I've been working on rewindtty, a lightweight terminal session recorder and replayer written in C. It works like script/scriptreplay, but outputs structured JSON and includes a browser-based player for replaying terminal sessions with timing, scrubbing, bookmarks, and more.

Until now, I was recording sessions command-by-command, capturing each shell command and its output separately. That made it easy to analyze sessions and index them by command.

However, I just introduced a new interactive mode, which behaves more like traditional script: it records raw terminal I/O in real-time via a PTY, capturing every character typed or displayed, including control sequences.

This is great for realism and full session fidelity (e.g. interactive tools like htop, vim, REPLs), but it makes command detection much harder — I'm no longer intercepting input at the shell level.

My question is: how can I extract actual commands from this raw PTY stream?

I'm aware it's tricky, but I'm wondering:

    Has anyone tried parsing the ANSI stream to reconstruct command boundaries?

    Is it possible to hook into the shell (bash, zsh, etc.) in real-time to intercept commands?

    Are there shell options or audit features that can be leveraged in parallel to raw capture?

    Any prior art or libraries I should look at?
I'd love to hear how others have approached this — either for recording, analyzing, or replaying shell sessions. Any insights or directions would be super helpful.

America Should Assume the Worst About AI

https://www.foreignaffairs.com/united-states/artificial-intelligence-geopolitics-worst-about-ai
1•voxleone•23s ago•0 comments

Instagram public accounts with less than 1k followers can no longer go live

https://www.engadget.com/apps/instagram-public-accounts-with-less-than-1000-followers-can-no-longer-go-live-133049758.html
1•bookofjoe•52s ago•0 comments

A parser and interpreter for a small language

https://blog.ploeh.dk/2025/07/07/a-parser-and-interpreter-for-a-very-small-language/
1•PaulHoule•2m ago•0 comments

What is Debounce and how does it work

https://developer.mozilla.org/en-US/docs/Glossary/Debounce
1•aanthonymax•2m ago•0 comments

Global Upswing in Photosynthesis Driven by Land, Offset by Oceans

https://nicholas.duke.edu/news/study-identifies-global-upswing-photosynthesis-driven-land-offset-oceans
1•geox•3m ago•0 comments

High-strength, low-temperature steel for first fusion reactor in action

https://www.mdpi.com/2076-3417/15/9/5201
1•LAsteNERD•3m ago•0 comments

The Exodus from the Washington Post

https://www.cjr.org/the_media_today/exodus-washington-post-wapo-storied-paper-dying-jeff-bezos-donald-trump.php
2•xrayarx•5m ago•0 comments

Ask HN: What change enabled you to consistently finish your side projects?

3•pillefitz•5m ago•0 comments

Qwen Image

https://huggingface.co/Qwen/Qwen-Image
2•error404x•6m ago•0 comments

AI agent friendly web browser which render HTML and CSS in Markdown

https://pypi.org/project/julia-browser/
1•mrxhacker99•6m ago•1 comments

Ocean-2 (wave power generation prototype) [video]

https://www.youtube.com/watch?v=Q7Pmgq2JKbI
1•imglorp•7m ago•0 comments

Hello Stranger

https://www.willdennis.com/blog/Hello-Stranger
1•williamldennis•8m ago•0 comments

Mobile app analytics library led to the PII exposure

https://www.cossacklabs.com/blog/how-mobile-app-analytics-library-led-to-the-pii-exposure/
1•punchvine•8m ago•1 comments

India's IT sector is shedding jobs

https://www.cnbc.com/2025/08/04/indias-it-layoffs-spark-fears-ai-is-hurting-jobs-in-critical-sector.html
2•belter•9m ago•0 comments

Ghost (CMS and publishing platform) version 6.0 adds support for the Fediverse

3•rglullis•9m ago•1 comments

Qwen-Image: Crafting with Native Text Rendering

https://qwenlm.github.io/blog/qwen-image/
1•meetpateltech•10m ago•0 comments

Fine-tuned small LLMs can beat large ones with programmatic data curation

https://www.tensorzero.com/blog/fine-tuned-small-llms-can-beat-large-ones-at-5-30x-lower-cost-with-programmatic-data-curation/
1•GabrielBianconi•11m ago•0 comments

The Ghost in the Graph, Pt. 2, or Why Winning Big Is the Fastest Way to Lose

https://vasily.cc/blog/the-ghost-in-the-graph-pt2/
1•staph•12m ago•0 comments

Show HN: Grant Writing AI for Nonprofits

https://www.grantboost.io/
2•EzenwaO•12m ago•0 comments

Split Flap

https://fx.hot.page/split-flap
2•eustoria•13m ago•1 comments

The Gulf's trillion-dollar AI dream faces a water crisis

https://restofworld.org/2025/gulf-ai-water-crisis/
3•colinprince•14m ago•0 comments

Moravec's Paradox: Towards an Auditory Turing Test

https://arxiv.org/abs/2507.23091
1•belter•15m ago•0 comments

Earth, Mars, Venus, and a lost planet once 'waltzed' in perfect harmony

https://www.livescience.com/space/planets/earth-mars-venus-and-a-long-lost-planet-may-have-once-waltzed-in-perfect-harmony-around-the-sun
3•Brajeshwar•15m ago•0 comments

Efforts to Ground Physics in Math Are Opening the Secrets of Time

https://www.wired.com/story/efforts-to-ground-physics-in-math-are-opening-the-secrets-of-time/
3•Brajeshwar•16m ago•0 comments

Mysterious boost to Earth's spin makes Aug 5 one of the shortest days on record

https://www.space.com/astronomy/earth/mysterious-boost-to-earths-spin-will-make-aug-5-one-of-the-shortest-days-on-record
3•Brajeshwar•16m ago•0 comments

Show HN: LLMs Play Monopoly Deal

https://dealbench.org/
1•advaith08•17m ago•0 comments

Anthropic beats OpenAI as the top LLM provider for business – and it's not close

https://www.zdnet.com/article/anthropic-beats-openai-as-the-top-llm-provider-for-business-and-its-not-even-close/
2•CrankyBear•17m ago•0 comments

Luzer, a coverage-guided Lua fuzzing engine

https://bronevichok.ru/posts/introducing-luzer.html
1•todsacerdoti•17m ago•0 comments

Why Universal Basic Income Is the Answer to Poverty, Insecurity, and Inequality

https://www.scottsantens.com/what-the-media-isnt-telling-you-why-universal-basic-income-ubi-is-the-answer-to-poverty-insecurity-and-inequality/
3•2noame•18m ago•0 comments

Third Man Factor

https://en.wikipedia.org/wiki/Third_man_factor
2•palad1n•19m ago•0 comments