Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to bind a tmux command to a key combination and use it directly without first pressing the prefix?

I find C-b + n too cumbersome to switch panes, so I was wondering whether I could bind C-1 for example, to switch to pane #1.

Or perhaps there may be a way to make the shortcut in the terminal emulator to send C-b + 1 when I press C-1?

Thanks!

share|improve this question
    
I just use set -g prefix C-a. –  grawity Jan 27 '11 at 20:31
    
Me too, I just put C-b on my question because that's the default. –  Ivan Jan 27 '11 at 23:05

1 Answer 1

up vote 18 down vote accepted

for your example, use:

bind-key -n C-1 select-pane -t 1

the -n argument to bind-key means no prefix.

share|improve this answer
    
Thanks! That almost gets it done, except it doesn't recognize numbers, it says unknown key: C-1. If I use a letter it works. Do you know how I can specify a number key? –  Ivan Feb 3 '11 at 12:36
3  
@Ivan: The usual codes for Control keystrokes come from ASCII. ASCII does not define codes for C-1..C-9. The standard ASCII control characters are C-@, C-a..C-z, C-[, C-\, C-], C-^, C-_, and C-?. Most terminals just do not support distinct codes for most modified keystrokes (though many support some modifiers for arrow keys and functions keys). You are probably better off using F1 in place of C-1 (also note that the pane numbers start at 0, not 1: bind F1 to selecting pane 0, F2 to 1, etc.). –  Chris Johnsen Feb 24 '11 at 5:22

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.