News for hackers. Stuff that matters.
Re:Ask HN: Teach me something new by darrelld on Friday April 29, 2022 @12:08PM (#31207011)
In your terminal Ctrl+a will return you to the start of whatever line you have typed, and ctrl+e will return you to the end.
Re:Ask HN: Teach me something new by Jtsummers on Friday April 29, 2022 @12:39PM (#31207423)
This is if you have emacs-based keybindings (which is the default). M-f/M-b (Meta, often the alt key or option key) will move forward/backward a full word. C-f/C-b moves forward/backward a character. C-w kills the previous word (if you're in the middle of a word it leaves everything from the cursor to the end intact).

C-r will search backward in your history allowing you to type partial matches (like, "I know I compiled foo.c, but what options did I use?" type `C-r foo.c` and repeatedly type C-r until I find the compiler command I used).

https://www.gnu.org/software/bash/manual/html_node/Bindable-... - for a lot more options

You can switch to vi keybindings with `set -o vi`.

Re:Ask HN: Teach me something new by tetris11 on Saturday April 30, 2022 @04:47AM (#31214425)
Aren't all terminal bindings emacs-based, since they inherit from libreadline?
Re:Ask HN: Teach me something new by O_H_E on Saturday April 30, 2022 @10:06AM (#31216178)
By default, yes. (Well, its not the terminal but the shell that takes input) but readline has support for vi bindings configuration
Re:Ask HN: Teach me something new by sph on Saturday April 30, 2022 @05:07AM (#31214503)
zsh doesn't use readline
Re:Ask HN: Teach me something new by tmaly on Friday April 29, 2022 @12:55PM (#31207635)
I use Ctrl+u if I think I might have added a typo in a password and have not yet typed enter
Re:Ask HN: Teach me something new by arnarbi on Saturday April 30, 2022 @02:03AM (#31213745)
This also works in any native text input on macOS.
Re:Ask HN: Teach me something new by primarydonkey on Saturday April 30, 2022 @02:07AM (#31213771)
On macOS, I also use ctrl+x go to the beginning of the line.
Re:Ask HN: Teach me something new by exikyut on Saturday April 30, 2022 @04:02AM (#31214224)
TIL there are scenarios where ^X doesn't just cut text.

(Never used macOS. Welp. Guess I have a lot of relearning to do.)