Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I found solution: use emacs -nw and function insert-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):

"\e[[A": "pressed up key"
"\e[[[A": "pressed F1"

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.

"\ej": backward-char
"\el": forward-char
"\ei": previous-history
"\ek": next-history
"\eh": beginning-of-line
"\eH": end-of-line
"\eu": backward-word
"\eo": forward-word
"\eg": kill-line
"\eG": backward-kill-line
"\ee": backward-kill-word
"\er": kill-word
"\ed": backward-delete-char
"\ef": delete-char
"\ez": undo
"\ex": kill-region
"\ec": copy-region-as-kill
"\ev": yank
"\e;": forward-search-history
"\e:": reverse-search-history

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 (because alias to same thing don't autocomplete)

"\ea\ei": "sudo aptitude install "

There are plenty other reasons why you should have your own ~/.inputrc ...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.