19

I use the Ctrl+B command prefix in tmux, however this clashes with Ctrl+B in less, which is used for scrolling up a file.

How can I get this to work? Do I have to set a different command prefix in tmux? I really don't want to have to learn new key bindings if I can avoid it.

4 Answers 4

20

Obviously you can't have two keys that do the same thing when both programs are listening. Tmux is going to get it first. You didn't specify which set of key bindings you don't want to re-learn, but you have to do something different because the same key is used for both apps.

If you only use it occationally in less you can just pass the real thing on by hit Ctrl+BB (that's Ctrl-B twice) in tmux to pass on a single Ctrl-B to the app in the current pane.

If you want to change the tmux binding to be something else (say like Ctrl+A like screen) you can add this to your `~/.tmux.conf file:

unbind C-b
set -g prefix C-a

If you want to use something else for less, the G key is usually bound to go to the top of the file already, so no changes necessary. If that change doesn't suit you, you can rebind keys using lesskey.

6
  • If I change the tmux binding to Ctrl+A, that will clash with beginning-of-command. I also have 'Ctrl+B+B' bound to previously selected window.
    – dogbane
    Aug 20, 2011 at 16:26
  • 1
    @Caleb: In my tmux (Ubuntu 11.04 with the default config), "Ctrl+B B" does nothing (nor is it documented in the man page); one has to use "Ctrl+B Ctrl+B" to send a Ctrl+B to the application. (By contrast, screen defaults to using "Ctrl+A A" to send a "Ctrl+A" to the application.) Excellent answer, anyway. Aug 20, 2011 at 16:28
  • 1
    @RiccardoMurri: That's a nomenclature problem. I didn't leave a space in between B keys that would indicate letting up on the control. Normally with styled keys like that you would put a space or comma between keys if the control key was going to be released, but it's not a well defined standard. Some people don't even use the same + syntax...
    – Caleb
    Aug 20, 2011 at 16:57
  • @dogbane: If you re-bound a double CTRL-B to something other than the default, that's your fault and you will either have to remap that, map the pass through version of CTRL-B to something else, or use a different key for less.
    – Caleb
    Aug 20, 2011 at 17:11
  • 2
    @dogbane I use Ctrl+\ , but this is obviously a matter of personal preference. You won't like my choice if you don't have a way of typing Ctrl+\ on your keyboard without finger contortions. Aug 20, 2011 at 23:57
19

In tmux with the default configuration, pressing Ctrl+B twice sends one Ctrl+B to the application.

7

You can use the tmux command send-prefix. It will send your tmux key-binding prefix to the current window

For example, in .tmux.conf:

set-option -g prefix C-a
bind-key v send-prefix

Then, pressing Ctrl-a + v will send Ctrl-a to the terminal.

0

You could try using Page Up ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .