Skip to content

Reclaim the Terminal

nishantjosh.dev
4 pointscat-whisperer2 comments
On HN

Comments

This is where my mental model had been backwards. Your keystrokes never go “to stdin.” They go to the terminal, and fd 0 is just a descriptor that usually happens to point there. When the shell pointed fd 0 at a pipe instead, the keyboard did not go anywhere; the process only lost its usual pointer to it. Opening /dev/tty makes a new one. This is what less is doing when you press j: the file arrives on stdin, and your keystrokes come from the terminal.

Oddly enough, I asked ChatGPT about the same thing probably about a month ago. I understood well enough at the time, but I like this explanation better.

Something else I've learned about using computers is that it's possible to have blind spots for pretty much arbitrarily long.

Yup, I had so many misconceptions, and during this I got them cleared out. It was pretty cool, rust is so good for such little experiments, LSP helps a bunch

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.