Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

131–140 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#131

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…

> “ I try to move my cursor up to edit a previous line using C-p and end up brining up a print dialogue. ” I used to be a big enthusiast of keyboard shortcuts, now I’m getting fed up of how many there are, every program has a zillion shortcuts all stacked on top of each other. Someone needs to come up with a better way (cough Jeff Raskin THE?). This one is notably egregious, hands up anyone who prints often enough to…

In KDE one can unbind Ctrl-P from print for all KDE apps, from the web browser to the PDF reader to the mail client.

Re: Keyboard shortcuts for GNU Readline

#132
Lots of comments about small improvements to typing efficiency. It is an important topic.

One thing I do, is turn the key repeat speed up as fast as I can stand, and turn the delay to repeat down as low as possible. I have always done this and over the years I've experimented to find the fastest possible settings.

On the Mac, use:

defaults write NSGlobalDomain KeyRepeat -int 1

defaults write -g InitialKeyRepeat -int 7

See: http://hints.macworld.com/article.php?story=2009082319301814...

After getting so used to these fast speeds, when I see folks attempting to type with the slow default speeds ... it is quite hilariously slow and I must confess I feel a little pity for them.

Re: Keyboard shortcuts for GNU Readline

#133

Earlier quoted context omitted.

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.

Also on macOS and (at least within emacs) Windows.

Re: Keyboard shortcuts for GNU Readline

#134

Lots of comments about small improvements to typing efficiency. It is an important topic. One thing I do, is turn the key repeat speed up as fast as I can stand, and turn the delay to repeat down as low as possible. I have always done this and over the years I've experimented to find the fastest possible settings. On the Mac, use: defaults write NSGlobalDomain KeyRepeat -int 1 defaults write -g InitialKeyRepeat -int…

Or just M-42 f to press f 42 times. In vi, 42 i f esc, works for sequences too.

Re: Keyboard shortcuts for GNU Readline

#135
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

I don't want to discount how valuable this may be to you. However, for the average sysadmin, or developer who spends time in shells on many different machines, I would gently suggest that this is not a good idea. It's not a significant enough improvement over the way it works out-of-the-box to merit both (1) not getting used to Ctrl-r and (2) getting used to a different behavior for the arrow keys. Just my opinion, o…

If you're the sysadmin, then chances are high you can add this to the base image of all the systems you regularly touch.

Re: Keyboard shortcuts for GNU Readline

#136
post #104
post #58

Earlier quoted context omitted.

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…

>The reason you use them is that they allow you to not leave the home row How do you press the control key or the alt key while touch typing without loosing home row position? For alt, I try using my thumb, extremely folded down, but for control...?

Your pinky. Many do remap ctrl to caps-lock, though, since it's more ergonomic and caps-lock is a bit useless anyway.

Re: Keyboard shortcuts for GNU Readline

#137
post #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.

Yes, there are quite a few places where you can, but not enough. Most software can't be changed.

And while you can edit (remap) the keybinds in [neo]Vim, there are limitations. You can't edit all of them at the same time without running into race conditions. I've tried and failed.

And even Emacs - a nearly best-case scenario - is a struggle. First, you have to remap all the Emacs functions you want to change. Then you have to remap all the plugins you use. It's a lot of unnecessary work, and it's tricky to find your way around.

Re: Keyboard shortcuts for GNU Readline

#138

Two issues with readline: it's GPL and it's big. For embedded systems intended to become products you really need something else. My tiny variant is this, but for sure there are many others: https://github.com/nklabs/libnklabs ("nkreadline" has editing, tab-completion (for embedded "nkcli" commands) and history)

For me as a customer, the GPL is a feature, not an "issue."

Of course, if you ship software for your hardware and want to lock your customers out of their own hardware, then I can see why you'd not choose it.

Re: Keyboard shortcuts for GNU Readline

#139

It's perhaps worth mentioning the smaller and more liberally licensed editline library if you want to embed the same line-editing functionality in your own CLI. It's been used in non-GNU Unixes for decades. https://troglobit.com/projects/editline/ See also the note at the bottom of that page about other versions of editline/libedit.

"liberal" is in the eye of the beholder.
Post reply on HN