Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I’m stuck here:

Is it possible to bind one of <enter>, <backspace>, <up>, <down>, <left>, <right> together with control?

\C<foo> shows up as |foo> in the help and ^<up> isn’t bound.
'\C<foo>, '\C <foo>' don’t work, too (same with " instead).

<control> doesn’t exist.

You actually can get ^<foo> to show up in the help, but only if you map ^<foo>, which isn’t exactly what I want. ;)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

First, you need to determine whether your terminal sends different escape sequences for these key combinations. Applications running in terminals get characters as input, not keys. Function keys are encoded as control characters or as escape sequences beginning with the escape character (which you can write as \e in a key binding).

To see the escape sequence sent by a key combination in a terminal, press Ctrl+V at a shell prompt, then press the key combination. For example, if I press Ctrl+V Ctrl+Left at a shell prompt, I see ^[O5D. ^[ is the escape character, so I would need to bind \eO5D in Mutt to make it react to Ctrl+Left:

bind editor \eO5D backward-word

Some terminals send the same escape sequence for the same key with different modifiers. If that's the case, you'll need to figure out how to change the terminal's behavior or switch to a different terminal.

share|improve this answer
    
Sounds good, but it doesn’t work. \e is the escape key, not the escape character… –  Profpatsch Feb 6 '13 at 12:23
    
@Profpatsch Weird, that binding works for me. I've been using Mutt 1.5 since about forever, maybe 1.4 works differently? Does it work if you use \e in a macro: macro editor \e[O5D \eb? –  Gilles Feb 6 '13 at 12:47
1  
I’m on Terminator, when I hit Ctrl+Down I get ^[[1;5B, it doesn’t work with bind index \e[1;5B command and not with \e1;5B , too. Oh, I work with Mutt 1.5.21 (Arch. ;) –  Profpatsch Feb 6 '13 at 13:48
    
@Profpatsch Ok, I can reproduce this. There seems to be a limitation to 5 characters: bind editor \e[1\;5 backward-word works for me (and inserts an extra D when I enter ESC [ 1 ; 5 D), but bind editor \e[1\;5D backward-word results in ESC [ 1 ; 5 D doing nothing. I see a limitation to 8 characters in the source code (MAX_SEQ), but nothing that would trigger at 5 characters. –  Gilles Feb 6 '13 at 15:33
    
@Profpatsch A workaround would be to make your terminal send shorter sequences. I don't know if Terminator supports this. –  Gilles Feb 6 '13 at 15:35

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.