Hacker News new | ask | show | jobs
by davegauer 1399 days ago
This is an excellent and entertaining intro to the world of TTYs and I think the first question is a particularly clever way to introduce it:

> The answer is Ctrl+W. Because Ctrl+W is provided by something called TTY, and the other three are provided by the shell.

My only criticism is a pet peeve of mine: screenshots of terminals. I know it's more work to copy/paste and make sure formatting is correct, and you lose the ANSI colors. But it just feels so wasteful and inaccessible (<img alt="tty">).

4 comments

You can use the script(1) utility (from util-linux) to record a session and it will save the ANSI colors. This only works if you do it ahead of time, though. And if you're putting it in a pastebin, the color codes will get in the way.
There's also https://asciinema.org . It makes recordings which can be replayed just like video (colors and all), but weigh almost nothing and let you select and copy text. There are lots of examples on the main page.
There exists tooling to convert these typescripts into, for example, HTML output to include on your website. I use the script(1) util as part of my dayjob to create a bit of a trail when there are questions later.

Some terminal emulators also support dumping the buffer as HTML.

> There exists tooling to convert these typescripts into, for example, HTML output to include on your website.

Indeed, I mentioned aha in another comment.

> Some terminal emulators also support dumping the buffer as HTML.

That's a nifty feature that I haven't run into yet. Seems like it could be quite useful.

Konsole does HTML export and the HTML is simple/editable (only inline styles, insignificant whitespace removed, output as-shown, not as-generated, so e.g. a progress bar is just a single line of text, not however many times it was updated).
You could preserve the colors with some CSS, even :) I have the sudden urge to write a small tool/some CSS that can automatically convert bits of terminal output into ready-to-use fancy HTML+CSS.
Something like aha? (It's probably in your distro's repo)

https://github.com/theZiz/aha/

I knew that somebody would already have something ready that does this :) Thanks!
Agreed about the intro question, it took me from "I should know more about what tty means (after seeing it for many years)" to "I want to know!"
gnome-terminal has a "Copy as HTML" option which is great for this. It basically generates a <pre> tag with colours and basic styling.