Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

121–130 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#121
post #6

I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key). Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (…

> but it can be useful when you're outputting a lot of text (for example tailing a logfile).

Use "tail +F" and press ^C when you need to pause at some line. Press F to resume tailing.

Re: Keyboard shortcuts for GNU Readline

#122

For anyone using a Mac, the basic cursor movement commands available in readline and emacs—C-f, C-b, C-a, C-e, C-n, C-p—are also available in virtually any text input in any program, namely web browser inputs, url bars, and textareas, as well as all system UIs. Once you get used to using these shortcuts that means you can compose and edit text anywhere without ever moving your hands. I recently switched to using Linu…

On Mac Os you can also add some other ones that are not enabled by default, there's various write ups on how to do this. https://irreal.org/blog/?p=259 I really missed C-w for delete word personally. There's also a vim plugin by tim pope that adds a few readline keys that don't clash. https://github.com/tpope/vim-rsi And if you use the fish shell you can have both vi and Emacs shortcuts activated at the same time for…

Until you get used to C-w in any text box, and then randomly close browser tabs (ff on Linux) because muscle memory.

Re: Keyboard shortcuts for GNU Readline

#123
post #58
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

C-f(orwards) C-b(ackwards) The reason you use them is that they allow you to not leave the home row. So say you're writing something and need to move back and delete a mistype, it's much faster to do that with C-b C-b C-b backspace M-f than moving your right hand to the arrow keys and moving it back to type the letter and then moving it to the arrow keys again. Now, lot's of people can't be bothered to take the time…

> Similarly, most programmers I personally know can't touch type.

OMG, seriously?

Re: Keyboard shortcuts for GNU Readline

#124

I have two frustrations with keyboard shortcuts that I think most people generally share: 1. They are usually inconsistent, so muscle memory conflicts. 2. You usually can't edit them. If only we could just edit them. The possibilities....

Why can't you edit them? Have you looked at .inputrc? If not, read the article ;P. You can also certainly edit anything in vim/Emacs. On macOS, you can even remap the keyboard shortcuts in almost every GUI app--and even sometimes universally across apps due to conventions--because of how they try to model shortcuts as convenience for the menu bar.

Re: Keyboard shortcuts for GNU Readline

#125
post #121
post #6

I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key). Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (…

> but it can be useful when you're outputting a lot of text (for example tailing a logfile). Use "tail +F" and press ^C when you need to pause at some line. Press F to resume tailing.

WAT

I always use -f then cancel out when I think I see what I want, I really need to read man pages for things I use

Re: Keyboard shortcuts for GNU Readline

#126

For anyone using a Mac, the basic cursor movement commands available in readline and emacs—C-f, C-b, C-a, C-e, C-n, C-p—are also available in virtually any text input in any program, namely web browser inputs, url bars, and textareas, as well as all system UIs. Once you get used to using these shortcuts that means you can compose and edit text anywhere without ever moving your hands. I recently switched to using Linu…

X11 supports all of this with user configurability but the cool kids threw all of it away.

Re: Keyboard shortcuts for GNU Readline

#127
post #15

"Shame, then, that even serious command line hackers never bother learning about its capabilities, as they can supercharge your command line productivity." Because it is really confusing if you are not an emacs user.

> Because it is really confusing if you are not an emacs user.

Or a make user -- the text input widgets on macOS natively interpret ^a, ^f, and other basic Emacs commands, and have since the NeXT days.

Re: Keyboard shortcuts for GNU Readline

#129

Earlier quoted context omitted.

Very cool! What keys do ~ and ^ represent? { "^w" = "deleteWordBackward:"; "~f" = "moveWordForward:"; "~b" = "moveWordBackward:"; "~d" = "deleteWordForward:"; "~ " = "moveToEndOfDocument:"; "~w" = "copy:"; "^y" = "yank:"; "^t" = "transpose:"; "^p" = "moveUp:"; "^n" = "moveDown:"; "^u" = "deleteToBeginningOfLine:"; }

In this file `~` is meta (option key on macs). Not sure why it's not escape like it is in emacs.

On Linux, Meta is activated on modern keyboards by both ESC and ALT.

Re: Keyboard shortcuts for GNU Readline

#130
post #43

Earlier quoted context omitted.

You can enable "Emacs bindings" in a bunch of applications. Enabling that in GTK would let you use the cursor movement keys in Chrome and Firefox. https://askubuntu.com/a/1280532

Unfortunately, GTK 4 has removed key themes. Eventually, Firefox, Chrom(e|ium) and all actual GTK applications will migrate to GTK 4, so this is not very future-proof. I use a variant of the emacs key theme, so I'd be happy if there were a workaround...

It's unfortunate that the GTK devs feel they have to remove features which their users find useful to keep GTK maintainable. Keeping software complexity under control is a difficult task, and I can't begrudge them their choice.
Post reply on HN