Lurker News
A command line trick, a random factoid, anything that’s interesting to you.

Comments (762) 128 threads

Show all comments

Showing thread 54 of 128

darrelld3 replies#
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.
Jtsummers1 reply#
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`.

tetris112 replies#
Aren't all terminal bindings emacs-based, since they inherit from libreadline?
sph#
zsh doesn't use readline
O_H_E#
By default, yes. (Well, its not the terminal but the shell that takes input) but readline has support for vi bindings configuration
tmaly#
I use Ctrl+u if I think I might have added a typo in a password and have not yet typed enter
arnarbi1 reply#
This also works in any native text input on macOS.
primarydonkey1 reply#
On macOS, I also use ctrl+x go to the beginning of the line.
exikyut#
TIL there are scenarios where ^X doesn't just cut text.

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