Live data from Hacker News

Entering text in the terminal is complicated

jvns.ca

81–90 of 229 posts

Re: Entering text in the terminal is complicated

#81
post #64

Earlier quoted context omitted.

It's provided by the terminal (emulator) in "cooked" mode: https://en.wikipedia.org/wiki/Terminal_mode raw mode doesn't do this.

To be clear, it's not the terminal emulator (xterm, mintty, iTerm2, etc.) that does this. It's the tty layer. You can use the stty command to change the settings.

Yes, quite right. I was thinking of the terminal driver and typed emulator for some reason. Good catch.

Re: Entering text in the terminal is complicated

#82
I've never seen dash dump escape sequences instead of acting on arrow keys. Probably, it's due to a missing or wrong TERM value?

Nowadays, programs should be hard-coded to accept ANSI sequences and ignore TERM (unless they need to make some fine-grained distinction like do we have 256 color xterm compatibility).

Those programs will never have that problem of not understanding arrow keys.

Re: Entering text in the terminal is complicated

#83
post #19

I have continually contented that the terminal is the single thing eternally condemning Linux to It's not just entering text. The entire experience is complicated. It's a Concorde jet cockpit[1] (with no labels too), when 95% of the population just wants to fly their drone around[2]. [1] https://qph.cf2.quoracdn.net/main-qimg-2566f4c91b894e4169d77... [2] https://media.thedroningcompany.com/images/tincy/WQZpC56vqMp...

Linux the kernel + some userland without terminal is used by majority of people in the form of Android and Chromebooks. A terminal is a developer and sysadmin tool. It just so happens that most users of desktop GNU/Linux are developers and sysadmins. They are a few percent of population.

>Linux the kernel + some userland without terminal is used by majority of people in the form of Android and Chromebooks.

Exactly, so why hasn't the open source community driving free distros taken note of this?

Now more than ever, people want out of Windows, but the only they step into the seat of exit craft and see the above cockpit.

Re: Entering text in the terminal is complicated

#84
post #21

> First, there’s “the baseline” – what happens if a program just accepts text by calling fgets() or whatever and doing absolutely nothing else to provide a nicer experience. [...] there are actually a few features that you get for free just from your terminal, without the program needing to do anything special at all. The things you get for free are: [...] - backspace - Ctrl+W, to delete the previous word - Ctrl+U, t…

Programs like zsh, bash, ksh, fish and most TUIs put the terminal into cooked mode so that they can manage the terminals behavior manually. In cooked mode, the terminal is not new line buffered and instead every character is read. The terminal only appears to be new line buffered but is actually being managed by the shell, which then in turn allows the devs to add nice features like manipulating the text buffer to do tab completion or prepend the line with sudo.

Re: Entering text in the terminal is complicated

#85
post #40

Earlier quoted context omitted.

> As computer lovers, I feel we must endeavour to remain mindful that almost everyone else aren’t like us. They’re trying to get a task done. They don’t want to maintain or talk with the computer. This was pretty much my point. 95% of the population isn't like us, and don't need to interact with the terminal; thus, thinking the terminal is what's keeping Linux back doesn't make much sense to me

The larger issue is the times that the Linux UX goes off the rails and the solution turns out to be "You're going to have to bleat this esoteric incantation at the command line." I plugged my laptop into a second monitor the other day and, oops, for whatever Godforsaken reason it didn't auto-detect. Suddenly I'm munging around in `xrandr` to get my screens to work. To its credit, all the major desktop distributions t…

The alternative is "it just won't work". You too can live in that world by simply not trying to fix it.

My wife's Macbook won't suspend correctly when it's plugged into a Dell monitor, the monitor going into power save wakes up the laptop. I wish there was an arcane incantation that would fix it, but no, the proprietary walled garden is well locked up, with glossy user-friendly rounded corners everywhere.

Re: Entering text in the terminal is complicated

#86
post #70

This is nice. As always, Julia's articles are always a win. Here's some stuff that's missing: Within shell scripts, you can use `stty` to change a lot of stuff about the terminal, including how it deals with inputs. You can rewire all of these defaults and behaviors. Here's an experiment I did a while ago using sh and stty: https://gist.github.com/alganet/63f1dbc97b8fd35f7bb14ec30f79... It is able to capture and unde…

friendly reminder to always check before you slurp code directly to bash from the internet. this may have broke my (admittedly totally non standard) configuration in weird ways I didn't care to document.

Re: Entering text in the terminal is complicated

#87
post #7

In bash, if you set $EDITOR to your favorite text editor, you can send the current line to $EDITOR with ctrl-x ctrl-e. After editing the command you can save and exit for the command to execute.

Or even just bind it to ctrl-e in bash:

bind '\C-e: edit-and-execute-command'

Re: Entering text in the terminal is complicated

#88
post #19

Earlier quoted context omitted.

Linux the kernel + some userland without terminal is used by majority of people in the form of Android and Chromebooks. A terminal is a developer and sysadmin tool. It just so happens that most users of desktop GNU/Linux are developers and sysadmins. They are a few percent of population.

>Linux the kernel + some userland without terminal is used by majority of people in the form of Android and Chromebooks. Exactly, so why hasn't the open source community driving free distros taken note of this? Now more than ever, people want out of Windows, but the only they step into the seat of exit craft and see the above cockpit.

> free distros taken note of this?

Gnome tries hard to emulate Apple's approach. Results are mixed, but I've seen fans of it.

Elementary OS goes in the "normal users" direction, too.

OTOH if something goes badly wrong, and you do need to open the hood and follow an arcane tech support recipe, you open a command line, be it Linux. macOS, or Windows. (Not Android or iOS though, where you do a reset + restore dance.)

> people want out of Windows

Yes, here's where they meet Steam Deck, that did take note, and just puts you into a cared-for gaming environment. It can also run a typical desktop. The hardware is proprietary, but the software is (mostly / completely?) free.

Re: Entering text in the terminal is complicated

#89
post #68
post #52

So when I use Windows Terminal and I press Ctrl-C, it always does the right thing: If I’m selecting text I want to copy it, if I’m not selecting text I want to kill the running process. On Linux, every Terminal app I’ve used stubbornly refuses to copy when I press Ctrl-C, demanding I press Ctrl-Shift-C. When I paste, if I forget my manners and use Ctrl-V instead of Ctrl-Shift-V, I am punished by getting a weird chara…

I copy from/to terminal with middle mouse button. Just select some text and click middle button where you want to paste the text. Some people don't like it because it needs a mouse, they prefer to keep their hands on the keyboard, but I don't see any issues with it. This way to copy/paste uses it's own Xorg buffer, so you can copy something with Ctrl-C and select something else, and then Ctrl-V will paste the first t…

> The trouble is programs running in terminal may want to deal with Ctrl-C by themselves. Text editors for example do that, but terminals have no way to know it. Terminals even don't know what program is running now, because job control is a job of a shell.

But then why does Windows Terminal (even when running against WSL) not have this problem? The terminal doesn’t need to know what’s running inside it to know “if text is selected, intercept Ctrl-C and copy the selected text”.

Re: Entering text in the terminal is complicated

#90

I have continually contented that the terminal is the single thing eternally condemning Linux to It's not just entering text. The entire experience is complicated. It's a Concorde jet cockpit[1] (with no labels too), when 95% of the population just wants to fly their drone around[2]. [1] https://qph.cf2.quoracdn.net/main-qimg-2566f4c91b894e4169d77... [2] https://media.thedroningcompany.com/images/tincy/WQZpC56vqMp...

However, GNU/Linux's better terminal experience compared to Unix could be part of the reason why it wiped the floor with Unix.

When you log into a BSD box, it's like taking a time machine back to the 1980s.

Post reply on HN