reddit / emacs
Keyboard Shortcuts every Command Line Hacker should know about GNU Readline
mickeyp · 2022-10-27 12:59
mickeyp · 2022-10-27 13:29
Keen to hear of cool macros and other `.inputrc` tweaks people do.
lindyhopdreams · 2022-10-27 15:30
Nice writeup!
olivuser · 2022-10-27 15:36
Do you have a RSS feed for the articles you publish? Since I've liked all articles you recently published, I'd really appreciate that!
mickeyp · 2022-10-27 15:46
I do, I must've removed the link at some point, but it's `/feed`
[deleted] · 2022-10-27 15:46
[deleted]
mickeyp · 2022-10-27 15:47
fzf is a command line fuzzy finder. ezf is my riff on it built entirely in Emacs (and a pinch of shell script.)
doolio_ · 2022-10-27 17:25
Is this sentence correct?
"If you’re using not using Linux, it may or may not be used at all."
doolio_ · 2022-10-27 17:48
For your Control + Meta bindings to you need to specify Meta i.e. \e first? For example, could your "\e\C-o" binding be "\C\e-o"? Thanks.
ovopax · 2022-10-27 19:20
I never knew about this. Thanks u/mickeyp !
agumonkey · 2022-10-27 20:37
I had a few nice ones back a few years, but the only one I kept is a binding to append
' | less -RS\r'
(something like C-x C-l)
ps: I just dug and I also have
"\C-x s": " `xsel`\r"
for quick terminal copy-pasting
big_lentil · 2022-10-27 20:43
Damn I actually learned something
mickeyp · 2022-10-27 20:44
Nifty! Good additions.
mickeyp · 2022-10-27 20:47
Good catch. Thanks!
chmouelb · 2022-10-27 20:54
this one is kinda useful : `"\es": "\C-asudo \C-e"` there is a bunch of useful ones and other tips in this french article (which i guess can be translated online) https://linuxfr.org/users/perdu/journaux/faire-de-la-magie-avec-son-inputrc
verdigris2014 · 2022-10-27 21:48
Off topic, but I was given a electronic copy of Mastering EMacs. The author has updated the book for every major release of eMacs and made the update available for free. That is amazing post sales support and shows the author is actively interested in tracking eMacs development.
Buy a copy if you’re interested in eMacs.
holgerschurig · 2022-10-28 04:57
My "coolest" hack to inputrc is to disable the infamous bell.
holgerschurig · 2022-10-28 05:01
What is this EMacs or eMacs? Some software that runs on iMacs?
I guess you mean Emacs :-) It's however good taste to not change the names of things by yourself.
c256 · 2022-10-28 06:13
If you see “eMacs”, it’s probably an autocorrect “fix” from an Apple product.
It was never popular, but near the end of the Newton product lifecycle, Apple made an education focused device based on the Newton hardware, with an attached keyboard and some extra sensors (I remember accelerometers) in translucent green plastic. It was called the eMac. I assume that it made it into some standardize dictionary and has stuck around as DYAC chaff ever since.
mickeyp · 2022-10-28 07:11
Thank you for your kind words :) I'm glad you like the book!
olivuser · 2022-10-28 08:09
Thanks :)
nullmove · 2022-10-28 12:14
Cool article. Another useful option is to do: `set enable-bracketed-paste on`. This prevents pasted commands with trailing newline from accidentally running (requires terminal emulator support but most already do iirc).
As for keyboard macros, I had a few defined but only really use one that goes up a directory (and a variant that goes to git project root). Sometimes I also use one that wraps previous command in `"$()"` and puts cursor at bol. This is a crude approximation of `evaluate-region` function I miss from (m)ksh, which apparently doesn't have a readline counterpart.
nullmove · 2022-10-28 12:35
Also I find shell-forward-word (M-C-f) and shell-backward-word (M-C-b) to be very useful. They only consider whitespace to be word separator, so go over things like dash, underscore, slash etc. during navigation.
I have a special variant of backward kill word that's useful for directory/urls. Imagine you have a term like: `this/is-a-folder`. Here backward kill word only deletes `folder` and `C-w` deletes whole thing, but I only want to delete up to the slash (is-a-folder). In a macro I do this by combining character-search-backward with shell-kill-word:
Control-Meta-h: "\M-\C-]/\C-f\M-\C-d"
asiledeneg · 2022-10-28 12:51
Good info but, a reminder that zsh does not use readline if that's your shell. zle is a bit more powerful.
mickeyp · 2022-10-28 13:17
Are you sure about that? For I cannot verify the claim that it does use readline. I cannot invoke my shortcuts from zsh.
asiledeneg · 2022-10-28 13:25
Typo. My phone changed not into to.
Does not.
mickeyp · 2022-10-28 14:11
Makes sense. I do point out in the article it won't work with zsh...
verdigris2014 · 2022-10-28 15:48
Thank you for understanding. It’s an iPhone. With a capital p that it gave itself, and this is how it likes to write eMacs.
PhantomSeahorse · 2022-10-28 21:22
Relax
emacsomancer · 2022-11-02 14:10
rElax, surely