Earlier quoted context omitted.
> The terminal just happens to invisibly turn \n into \r\n. No, it was actually done by the Unixen itself, in the part of the kernel that handled ttys: it convert '\n' to '\r\n' on writes to ttys, and '\r' to '\n' on reads from ttys. Linux only recently have moved this functionality out into the user-land layer.
> in the part of the kernel that handled ttys Yes, that's what I meant. OPOST Enable implementation-defined output processing. That gets set in a termios structure that gets passed to the kernel's terminal subsystem via ioctl. https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... h…
Entering text in the terminal is complicated
201–210 of 229 posts
Re: Entering text in the terminal is complicated
#202Whenever someone brings up this subject, I'm reminded of this classic article from Linus which has appeared many times on HN: http://www.linusakesson.net/programming/tty/index.php
Re: Entering text in the terminal is complicated
#203This 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…
> 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 I've also found this article on implementing a terminal text editor to be illuminating: https://viewsourcecode.org/snaptoken/kilo/ https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode... Also, just in case anyone is wondering, as I once did, where many of th…
There's some "new" stuff as well (90's), like SIXEL graphics. I was surprised by how broad the support is (however not that broad to count on it).
Re: Entering text in the terminal is complicated
#204Earlier quoted context omitted.
> 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 I've also found this article on implementing a terminal text editor to be illuminating: https://viewsourcecode.org/snaptoken/kilo/ https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode... Also, just in case anyone is wondering, as I once did, where many of th…
I like your comparison with browsers. In many ways, the only way to know for sure is to test in the desired terminals and figure out what works on all of them. There's some "new" stuff as well (90's), like SIXEL graphics. I was surprised by how broad the support is (however not that broad to count on it).
Re: Entering text in the terminal is complicated
#205I plan to make one day an alternative to terminals. My idea is not fully fleshed out, but I would like to try to forgo TTYs altogether. Use only pipes, file descriptors and job control. The closest thing I saw to what I have in mind is this: https://github.com/letoram/cat9/ but more in a way of interface.
Re: Entering text in the terminal is complicated
#206Earlier quoted context omitted.
> in the part of the kernel that handled ttys Yes, that's what I meant. OPOST Enable implementation-defined output processing. That gets set in a termios structure that gets passed to the kernel's terminal subsystem via ioctl. https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... h…
Hmmm, I could swear I have read about moving line discipline out of the kernel in some LWN article but apparently no, it never happened (although it probably should've, there is no much reason to perform mapping of NL to CR-NL in the privilleged mode). Maybe I've confused it with what happened on the Windows side of things? They moved almost all of the console infrastructure out of the kernel recently and into the us…
Re: Entering text in the terminal is complicated
#207Earlier quoted context omitted.
I feel like you're being willfully obtuse here. I can't remember the last time I used a laptop which had Home / End keys. Edit: actually I do remember -- it was an HP ProBook from 2011.
For the complaint to make any sense in the first place there needs to be an expected alternative way to go back to the beginning and end of a line. Otherwise it would be "it took me maybe 15 years to get used to being able to go to the beginning or end of a line in one keystroke". The two such options I'm aware of are Home/End (on macbooks I believe that is Fn+arrow keys) and Ctrl-a/Ctrl-e. What alternative key combi…
jvns: I didn't know you could go to the beginning of the line
you: But you could have just pressed the Home key
The obvious answer is: jvns doesn't have a Home key.Re: Entering text in the terminal is complicated
#208Earlier quoted context omitted.
Oh I always do ctrl+shift+r for that last bit, like reverse-tabbing on a gui. Good to know about ctrl+s, though I imagine muscle memory will prevent me for ever using it. :)
normally control-shift-r is just control-r; both key combinations send the same byte, 0x12, so they both search backwards in readline history. is your terminal emulator doing something different? if you type control-v control-shift-r enter control-d as the input to the command od -t x1a, what does it say?
Re: Entering text in the terminal is complicated
#209Earlier quoted context omitted.
I think the command “reset” does something similar
You are correct! I think it does a little more (restoring cursor if hidden, etc). If you have it, it is probably better than `stty sane`
Re: Entering text in the terminal is complicated
#210So 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…
map ctrl+c copy_or_interrupt
https://sw.kovidgoyal.net/kitty/actions/#action-copy_or_inte...