Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select Pane with C-<number> in tmux

Tags:

tmux

In tmux, the default behavior for processing C-b 0 is to jump to window 0. I would like C-b C-0 to jump to pane 0 in the current window. My attempts at adding,

bind-key C-0 select-pane -t 0 

to my .tmux.conf have failed. Is there something else I'm missing?

like image 590
duckworthd Avatar asked Sep 05 '13 19:09

duckworthd


People also ask

How do you split a pane in tmux?

ctrl + b + " to make a Horizontal split. ctrl + b + left arrow to move to the left pane. ctrl + b + " to make a Horizontal split.

How do I move a pane from one window to another in tmux?

Key binding By default, Ctrl + b , ! would break the active pane into a new window and switch to it. Where Ctrl + b is the default prefix for tmux.

What is Ctrl B in tmux?

ctrl-b, <arrow key> switch to the pane in whichever direction you press. ctrl-b, d. detach from tmux, leaving everything running in the background.


2 Answers

Not exactly the way you are looking for, but I doubt you have a reason not to love the following:

  1. display-panes or the likes (<prefix> + q by default),
  2. enter the number of the pane you are switching to.
like image 55
Covi Avatar answered Sep 21 '22 16:09

Covi


You need to modify your terminal so that tmux can recognise control+digit keystrokes correctly. (source: https://unix.stackexchange.com/questions/96884/using-ctrl0-9-to-cycle-between-windows-using-tmux)

If you are using iTerm2, for example, then:

  1. go to Preferences > Profiles > Keys and click +
  2. input ctrl+0 as the keyboard shortcut
  3. select Send Escape Sequence from the action drop-down menu
  4. input Esc+[27;5;48~ in the characters to send textbox
  5. click OK, then restart iTerm

Then, finally add to your .tmux.conf the following:

bind-key C-0 select-pane -t 0 

restart tmux (make sure to close all sessions withtmux kill-session). You should now be able to select pane number 0. To get the other 9 keys to work, repeat the above 5 steps with the appropriate escape sequences. They can be found in the link provided.

like image 28
James Lawson Avatar answered Sep 20 '22 16:09

James Lawson