Live data from Hacker News

Entering text in the terminal is complicated

jvns.ca

101–110 of 229 posts

Re: Entering text in the terminal is complicated

#101
post #29
post #18

> took me maybe 15 years of using the terminal every single day to get used to using Ctrl+A to go to the beginning of the line (or Ctrl+E for the end). And the curse of bad defaults strikes again (daily). After the realization that this is a weird default you don't train yourself for 15 years, but change it to your comfortable/common keybinds!

I wonder what terminal that is, because the Home and End keys, which I'm pretty sure are the expected alternatives, work fine in every terminal for me on Linux.

There are many keyboards without home and end keys.

Re: Entering text in the terminal is complicated

#102
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…

On Sonoma I get: The invoked shell does not support interactive features

I don't have a mac here, but you might try replacing `bash` with `zsh` to see if zsh fares better. Sonoma should have it by default.

If I remember correctly, macos bash (3.2) is 19 years old. I don't think I tested it with that version back then.

Re: Entering text in the terminal is complicated

#104
post #42

I think the lowest hanging fruit would be doing something (anything) to improve discovery of commands. I have great grokking abilities but terrible memorization skills, and I end up forgetting how to do what I want to do and maybe even have done before. Browsing man pages for every command is my bane. It's also why I dislike GUI with unlabelled icons, I never remember what each one does.

fzf replacing my default ^R has been a godsend to me for remembering how to do things in the shell.

https://github.com/junegunn/fzf

Re: Entering text in the terminal is complicated

#105
Over 20 years ago now I wrote a state machine around readline that meant you could use it as a multi-line editor. Not "multi-line" as in a single line can wrap, but a true editor that lets you move up and down, but is windowless.

Here's a video:

    https://github.com/colmmacc/jot/raw/master/jot-demo.mp4
and the CVS repository for the Unix terminal IM client it is part of is at:

    https://c-hey.redbrick.dcu.ie/src/c-hey_cvs_latest/
It tracks and redraws your cursor when you move up and down between lines, and also pays attention to SIGWINCH to redraw things when the terminal size changes. I've never had the time to rewrite it in Rust, but I'd like to and then release it as a small library.

It's always surprised me that nobody else has done this.

Re: Entering text in the terminal is complicated

#106
post #100
post #91

Earlier quoted context omitted.

that sounds horrific. every time you tried to go to the end of the line you'd get interrupted by launching an editor!

I always just use the home and end buttons for that kind of thing.

i don't even know where they are without looking at the keyboard. then when i try to press them half the time i accidentally press insert or print-screen instead

Re: Entering text in the terminal is complicated

#107
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 think you could achieve this in Wezterm, which is configurable with lua. Not on my laptop right now but will try to get it working later. I have other keybinds that run specific lua functions.

Re: Entering text in the terminal is complicated

#108
post #91
post #87

Earlier quoted context omitted.

Or even just bind it to ctrl-e in bash: bind '\C-e: edit-and-execute-command'

that sounds horrific. every time you tried to go to the end of the line you'd get interrupted by launching an editor!

I have `set -o vi` so, `esc` and `$` takes me to the end of the line. `ctrl-e` is unused for me unless I bind it to something I think is useful.

Re: Entering text in the terminal is complicated

#109
post #65

Earlier quoted context omitted.

I've always configured my terminal to copy on select. I never press ctrl-c. I mean, why would I want to select text if not to copy it?

E.g., to press Ctrl-(Shift)-V and replace the selection with something you copied (to the buffer / clipboard) earlier?

that doesn't work in terminal emulators because the terminal emulator doesn't know how to delete the selected text in whatever program drew it there (which may no longer even exist)

Re: Entering text in the terminal is complicated

#110

"The other day I asked what folks on Mastodon find confusing about working in the terminal, and one thing that stood out to me was "editing a command you already typed in". This really resonated with me: even though entering some text and editing it is a very "basic" task, it took me maybe 15 years of using the terminal every single day to get used to using Ctrl+A to go to the beginning of the line (or Ctrl+E for the…

yes, fc is from ksh

going to a particular column number is not useful to me because my commands are not on punched cards with column numbers printed on them. going to a particular piece of text is, and ^r or ^s gets me there with readline (in vi mode or emacs mode). i don't want to mentally count how many characters are on the line before the place i want to go; i have a computer to do that for me

vi movement by words is useful though, and slightly easier than emacs alt-f and alt-b

Post reply on HN