What I struggle with:
I'm configuring ~/.inputrc
file to be same as mine custom emacs key-bindings and I'm struggling very much with readline's key sequences.
What I mean by that is that if I want to set <up>
/ <down>
, I have to set it to "\e[A"
/ "\e[B"
How can I infer keyseq for <F1>..<F12>
or even if I want to bind something to let's say (kbd "C-x <M-f7>")
in emacs terminology (ie: to [control]+[x] [alt]+[f7]
be one keyseq)?
What I want:
Is there any command that tells me for certain key on keyboard what its escape sequence? If there isn't any command, is there any other resource (article/table/...) with some hints?
--> goal: replace <KEY SEQUENCE> with proper keyseq
"<f3>" : start-kbd-macro
"<S-f4>" : end-kbd-macro
"C-x <C-M-S-f4>" : dump-macro
"<f4>" : call-last-kbd-macro
... more keybindings ...
I found solution: use
emacs -nw
and functioninsert-quoted
(default bind to Ctrl+q).Ctrl+q ↑ will result in
^[[A
Ctrl+q F1 in
^[[[A
Lines in
~/.inputrc
will then be following (results may vary depending on environment - mostly $TERM variable):Motivation to change your .inputrc can be following.
Don't you like emacs-like keys for navigating along line and history?
I don't and I prefer ErgoEmacs key bindings because they are logical and I want to use them not only in Emacs but system wide.
I have written "sudo aptitude install" so many times (usually after fresh install) that I have
M-a M-i
(ie Alt+a Alt+i) as shortcut for that (becausealias
to same thing don't autocomplete)There are plenty other reasons why you should have your own
~/.inputrc
...Vim readline filetype & syntax
I found that Vim has a readline filetype plugin, which can help to rewrite your
.inputrc
.The plugin should auto-detect
.inputrc
, and if not you can call:set filetype=readline
to select it.Assuming you have an empty line such as
"": readline-command
you can place your cursor inside the "" quotes in insert-mode (i) and then press Ctrl+V then keystroke-combination to insert many of the more magical incantations.Assuming syntax completion is on you can auto-complete readline commands.