Live data from Hacker News

Everything you ever wanted to know about terminals

xn--rpa.cc

51–60 of 191 posts

Re: Everything you ever wanted to know about terminals

#51
Yeah this is very very far from "everything". Among many things it doesn't speak of ptys.

And terminfo, pty, ctty, process groups, and the rendering width of a utf-8 string, and, and and…

> i might be one of a handful of people left on earth who actually has the knowledge to

Uh, no. Anyone on BBSes in the 90s is very aware of ANSI, thank you. And we've not died off yet.

And honestly it's really not that hard at all. Even on the topic of terminals this is not even the hardest aspect of it.

> i have effectively zero pull in the tech community

If you think there's all there's to terminals, yet you act as if you know it all, then you shouldn't have any pull.

I would also not accept any pull request that looked even remotely like their example code.

Here's a more interesting article about a less understood aspect of terminals: http://www.linusakesson.net/programming/tty/index.php

Re: Everything you ever wanted to know about terminals

#52

You can't have "everything you wanted to know about terminals" with absolutely no mention of terminfo and (previously) termcap. You don't necessarily need ncurses to have a portable smart terminal experience, but you do need terminfo. ncurses magic relies on the lore stored in terminfo, which contains all of the obscure escape sequences and other information about the disparate world of terminals. They're maintained…

As the article states: > being compatible only with ANSI-capable terminals is a feature, not a bug Driving old hardware terminals (as opposed to terminal emulators) is a fun stunt, not something of actual modern value. Every modern terminal emulator supports ANSI escape sequences. Some features are supported by a subset of terminals, but you can either 1) probe for those features by asking the terminal, which some te…

> Every modern terminal emulator supports ANSI escape sequences

Is this true on Windows? My understanding is that quite a few TUI libraries don't have windows support.

Re: Everything you ever wanted to know about terminals

#53
post #40

A while ago I was trying to find a way to make my terminal scroll back up after a command executed, so that if the output was long I could read it from the top without having to scroll up manually. There are ways to get yours shell to print something after the command executes, so I just needed to find an ansi escape sequence that would scroll up. Unfortunately I didn't see any sequences that do this. Anyone have any…

Once it's scrolled off the top of the screen you're basically at the mercy of your terminal emulator's scrollback history. Some might have an escape sequence available to recall it but I there isn't any standard way of doing it.

You'd be better off piping into less / more / most. These are called "pagers" and are designed to do this. eg

    cat large-file | grep common-phrase | less

Re: Everything you ever wanted to know about terminals

#54
I'm sure this is very interesting but I couldn't make it past the first sentence. I'm sure there's a term for someone who writes like this, but all I could think was "redditspeak," or otherwise stale tryhard wacky. Forcibly inserting so much 'character' into your sentences that your syntax implodes.

Re: Everything you ever wanted to know about terminals

#55

I could take this a lot more seriously if capital letters were properly used.

I was actually thinking the opposite. I got quite a way through the article before I realized "Hang on - None of the paragraphs and sentences start with uppercase letters!"

As a father trying to teach two small children to read and write, I've begun to think it's kind of annoying and unnecessary to have two different forms. It's easy enough to teach when they are just bigger glyphs, e.g. O -> o, C -> c, S -> s, etc. But having uppercase and lowercase that are entirely different is just a pain in the ass, e.g. A -> a, D -> d, G -> g, R -> r, etc.

I do wonder if literacy might be improved if we got rid of uppercase, to little to no detriment elsewhere. (I'm sure someone here can probably sight some data on that!)

Re: Everything you ever wanted to know about terminals

#56
post #40

A while ago I was trying to find a way to make my terminal scroll back up after a command executed, so that if the output was long I could read it from the top without having to scroll up manually. There are ways to get yours shell to print something after the command executes, so I just needed to find an ansi escape sequence that would scroll up. Unfortunately I didn't see any sequences that do this. Anyone have any…

Maybe pipe output of every command into a script that invokes $PAGER when the output is long enough?

less has a flag for that: (the gnu version does at least)

       -F or --quit-if-one-screen
       Causes  less  to automatically exit if the entire file can be displayed on the
       first screen.
So one could just pipe everything through `less -F`. If a different $PAGER is preferred, well that'll be a little more involved.

(Also handy: add in `-X` to leave the contents on the screen when you exit less)

Re: Everything you ever wanted to know about terminals

#57

You can't have "everything you wanted to know about terminals" with absolutely no mention of terminfo and (previously) termcap. You don't necessarily need ncurses to have a portable smart terminal experience, but you do need terminfo. ncurses magic relies on the lore stored in terminfo, which contains all of the obscure escape sequences and other information about the disparate world of terminals. They're maintained…

As the article states: > being compatible only with ANSI-capable terminals is a feature, not a bug Driving old hardware terminals (as opposed to terminal emulators) is a fun stunt, not something of actual modern value. Every modern terminal emulator supports ANSI escape sequences. Some features are supported by a subset of terminals, but you can either 1) probe for those features by asking the terminal, which some te…

You don't need terminfo until you need to redirect those fancy outputs to a file, or you see a lot of weird [M; in your CI logs, or your ssh session does not display full 256 colors, or you question why we don't have true images in our terminals when we have bitmap escape codes for decades now[1]. No terminal was created equal and never will. terminfo is about future as it is about the past.

Color ansi codes might be everywhere today, but that's no reason to disgrace terminfo, there are a ton of other features that need checking and are not universal.

[1]: https://en.wikipedia.org/wiki/Sixel

Re: Everything you ever wanted to know about terminals

#58

The author seems not to be aware of the recent TUI rennaisance[1]. There are libraries like termbox and blessings (python) that are a middle-ground between full ncurses and adding your own ansi codes. There are a lot of modern TUI frameworks like tui-go or tui-rs that bring common GUI conventions back to the TUI (heck there are TUI programming libraries that are designed to be similar to react) - these too tend to be…

or rich/textual, for python, which really heap the shiny up high!

Re: Everything you ever wanted to know about terminals

#59

The author seems not to be aware of the recent TUI rennaisance[1]. There are libraries like termbox and blessings (python) that are a middle-ground between full ncurses and adding your own ansi codes. There are a lot of modern TUI frameworks like tui-go or tui-rs that bring common GUI conventions back to the TUI (heck there are TUI programming libraries that are designed to be similar to react) - these too tend to be…

Make sure to check out Notcurses!

https://github.com/dankamongmen/notcurses#readme

demo: https://www.youtube.com/watch?v=dcjkezf1ARY

Re: Everything you ever wanted to know about terminals

#60

Earlier quoted context omitted.

I can’t agree more. An author who can’t be bothered to follow well established forms of style, grammar, and punctuation in a technical article somehow deflates whatever else they have to say even if accurate. It’s not as if they are trying to emulate the works of E. E. Cummings, James Joyce, or Arno Schmidt.

y'all are the most boring people on the planet istg. in the entire legion of internet writers making in depth technical content there is what, one who deviates from the conventions and you can't handle it. This author is a much much better writer than average for free technical content! They have an interesting, unique style! The typography and punctuation are part of that style! It would be tangibly worse if they ad…

We like what we like and we're allowed to like it. Same goes to you and her.
Post reply on HN