Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

161–170 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#161
post #24
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.

Not at all. bash readline is probably the productivity enhancer skill a developer (or system admin) can develop. Simple things like copy and paste without hitting a mouse. This will make you _prefer_ the cli as it is not slowing you down anymore.

Yes please. Teach me how to copy output of previous command into clipboard using keyboard only and I will love you forever. Bonus if I can have a cursor to only select partial lines of the output.

Re: Keyboard shortcuts for GNU Readline

#162
post #161
post #24

Earlier quoted context omitted.

Not at all. bash readline is probably the productivity enhancer skill a developer (or system admin) can develop. Simple things like copy and paste without hitting a mouse. This will make you _prefer_ the cli as it is not slowing you down anymore.

Yes please. Teach me how to copy output of previous command into clipboard using keyboard only and I will love you forever. Bonus if I can have a cursor to only select partial lines of the output.

Unrelated, but you could easily do that on screen with C-a ESC (default key binding)

Re: Keyboard shortcuts for GNU Readline

#163
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. That takes a few hours of practice with a fun, gamified touch typing program for a couple of weeks, and then you have set part of your mind free. But people can't be bothered.

I would argue that it takes more then a few weeks, be prepared to wait/invest several months into it, but it is absolutely worth the investment. 100%.

Re: Keyboard shortcuts for GNU Readline

#165

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…

Anyone using a Mac is probably not using readline but its replacement 'editline'.

So the configuration file is ~/.editrc.

man editrc

Note also that to have a full mapping of keys available to you, you have to be aware of the tty settings (see stty), the terminal emulator and the GUI environment in which it is running. I would appreciate a tool that would dump all this in a comprehensive list.

Re: Keyboard shortcuts for GNU Readline

#166
post #161
post #24

Earlier quoted context omitted.

Not at all. bash readline is probably the productivity enhancer skill a developer (or system admin) can develop. Simple things like copy and paste without hitting a mouse. This will make you _prefer_ the cli as it is not slowing you down anymore.

Yes please. Teach me how to copy output of previous command into clipboard using keyboard only and I will love you forever. Bonus if I can have a cursor to only select partial lines of the output.

You can pipe to xclip to get it into the copy buffer. Then "shift-insert" is often the right paste when "ctrl-v" doesn't work.

Re: Keyboard shortcuts for GNU Readline

#167
post #10

Earlier quoted context omitted.

>by far the most useful shortcut for me is Ctrl-r I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc` "\e[A": history-search-backward "\e[B": history-search-forward

a really cool hack I found in an HN thread long ago was to stick "hashtags" (aka bash end-of-line comments) at the ends of commands you want to find in your history quickly: sudo systemctl restart myservice #bounce and then ctrl-r and type your hashtag to get right to it

This is now the HN thread in which I found this really cool hack. Thank you.

Re: Keyboard shortcuts for GNU Readline

#168
Fun fact: GNU Readline and Bash are maintained by a single person. https://tiswww.case.edu/php/chet/readline/rltop.html#Maintai...

In case you were looking for more examples of "open source being held together by one tireless person somewhere" (obligatory xkcd comic link omitted).

Re: Keyboard shortcuts for GNU Readline

#170

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…

You find these all over the place[0]; I often try them and am unsurprised when they work. Have to train myself not to use ^w though. Try to erase word and it closes the window.

[0] for example in the quakelive console

Post reply on HN