Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

21–30 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#21
post #3

Just enable vim mode (`set -o vi`) and call it a day.

Yes! I never got the hang of the read line short cuts. Only one I remember and regularly use is reverse history search: ctrl-R.

The downside is that while vim mode works nicely on bash, other commands like gdb etc that also use read line aren’t as easy to get into vim mode, if they support it at all…

Re: Keyboard shortcuts for GNU Readline

#22
post #9

Earlier quoted context omitted.

I'd use "history | grep ..." at that point, if I can't remember an old command. Possibly "history | grep ... | less" and finish searching inside less.

I was doing history grep too until someone on HN told me about hstr: https://github.com/dvorka/hstr

Another similar tool that may be of interest is mcfly

https://github.com/cantino/mcfly

Re: Keyboard shortcuts for GNU Readline

#23
post #11

Knowledge like this used to spread naturally—physically sitting with a junior engineer, muscle memory would make any shortcut-fu gaps painfully clear. That’s not as visceral in remote pairing, and doesn’t show up at all in async processes like CR. Still, I try to at least share the “greatest hits”: ctrl-r: search backwards through command history ctrl-a: go to beginning of line ctrl-e: go to end of line If nothing el…

In ~20 years of professional programming, I have never explored much beyond these shortcuts, except for also using:

  * ctrl-left/ctrl-right to go back/forward word by word instead of char by char
  * ^C to cancel the current line

Re: Keyboard shortcuts for GNU Readline

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

Re: Keyboard shortcuts for GNU Readline

#25
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 Linux full time for my job and it KILLS me that these shortcuts aren’t available outside of the terminal. I try to navigate to a search suggestion in Chrome using C-n and accidentally open three new windows. I try to add a sentence at the start of Slack message using C-a and accidentally highlight everything and delete it. I try to move my cursor up to edit a previous line using C-p and end up brining up a print dialogue. It’s breaking the muscle memory of my most basic interactions with the computer, and it sucks.

Re: Keyboard shortcuts for GNU Readline

#26

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…

Command-A isn’t available on Linux in slack?

How do people even function without basic function keys?

Re: Keyboard shortcuts for GNU Readline

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

Re: Keyboard shortcuts for GNU Readline

#28
post #23
post #11

Knowledge like this used to spread naturally—physically sitting with a junior engineer, muscle memory would make any shortcut-fu gaps painfully clear. That’s not as visceral in remote pairing, and doesn’t show up at all in async processes like CR. Still, I try to at least share the “greatest hits”: ctrl-r: search backwards through command history ctrl-a: go to beginning of line ctrl-e: go to end of line If nothing el…

In ~20 years of professional programming, I have never explored much beyond these shortcuts, except for also using: * ctrl-left/ctrl-right to go back/forward word by word instead of char by char * ^C to cancel the current line

Oh my gosh thank you. I once went back by a word and swore I hallucinated, then realized the shortcut probably exists but never bothered to look into it.

Re: Keyboard shortcuts for GNU Readline

#29
Two settings I always set in my .inputrc which are not listed in the page:

  # Make autocompletion case insensitive and display suggestions after single tab.
  # https://bugs.debian.org/990353
  set completion-ignore-case On
  set show-all-if-ambiguous On

Re: Keyboard shortcuts for GNU Readline

#30

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

Post reply on HN