53

After searching through, I figured ctrl+b ( PREFIX ) then ctrl + arrow should resize the current pane. But it is not working. Am I missing anything ?

Thanks.

2
  • FYI, I did adjust the width with PREFIX : resize-pane, but still wondering why the above command should not work.
    – Biswanath
    Oct 15, 2013 at 3:33
  • should prob be on apple.stackexchange.com
    – Alex Leach
    Nov 29, 2013 at 15:39

6 Answers 6

54

Probably your terminal is not sending a (distinct) sequence when you hold Control and press an arrow key.

Try running cat and typing the keys into it (Control-C to quit). You will probably find that (e.g.) Up and Control-Up both generate the same sequence.

OS X Terminal application

In its default configuration the OS X Terminal application sends the sequence ^[[A (or ^[OA) whether you type Up or Control-Up (also any combination with Shift and Option, too).

However, you can reconfigure Terminal to send appropriate codes. It is a bit tedious, but you usually only have to do it once.

  1. Terminal > Preferences…
  2. Settings top-level tab
  3. pick the profile you want to modify
  4. Keyboard tab
  5. click the plus button to add a new binding

    • pick a cursor key
    • set the modifier to control
    • use the Send Text: action
    • type Escape (will show up as \033) followed by [1;5 and one more character:
      • A for Up,
      • B for Down,
      • C for Right, or
      • D for Left
    • click OK to add the binding

For example, the final sequence for Control-Up should end up looking like \033[1;5A.

These sequences are the ones that XTerm generates (see the ctlseqs documentation for details).

Repeat the last step for the other arrow keys.

iTerm 2

iTerm 2 sends the expected sequence by default.

8
  • 2
    Indeed, the Ctrl + { arrow keys} are mapped for switching application. They are not sending the sequence.
    – Biswanath
    Oct 20, 2013 at 2:41
  • 22
    I tried this on a vanilla Mavericks machine (MBP retina late-2013), but it didn't work without also deactivating all Ctrl+Arrow key shortcuts in System Preferences -> Keyboard -> Shortcuts -> Mission Control. +1 for the tip on using cat to see keyboard events
    – Alex Leach
    Nov 29, 2013 at 15:37
  • works fine until i start tmux. I get ^[[1;5A^[[1;5B before launching tmux, but ^[OA^[OB in tmux.
    – nakhli
    Apr 27, 2015 at 15:31
  • 2
    @Sinbadsoft.com: It sounds like you do not have xterm-keys enabled for that tmux window; you may want to set -gw xterm-keys on. Apr 27, 2015 at 21:21
  • 1
    every time I change my mac computer I have to waste my time with this crap, thanks apple! Jul 19, 2017 at 9:20
26

You can use the meta key instead of the control key in the ctrl-↑ and ctrl-↓ combinations. In OSX Terminal the default meta key is the escape key. For example, to increase the size of a pane type ctrl-b esc-↑.

I find the escape key a pain to reach so I use the option key as the meta key instead. In Terminal.app you can change it by going to Terminal > Preferences > Profiles > Keyboard : check the "Use Option as Meta Key".

Now you can type ctrl-b option-↑ to increase the size or ctrl-b option-↓ to decrease the size and you don't have to remap the mission control keys.

4
  • 1
    Using Escape was only solution as holding Ctr+Arrow by default on my MacOS shifts to another desktop.
    – klimat
    Jul 22, 2018 at 17:40
  • option(alt)-↑ works! Thanks!
    – Richard Li
    Oct 18, 2020 at 19:58
  • Thanks for this! I prefer this solution over "deactivating all Ctrl+Arrow key shortcuts" to make the accepted answer work.
    – markhops
    Apr 21, 2021 at 15:14
  • Love the escape key solution! "Simplicity is beautiful :)" ~William of Occam Jul 17, 2022 at 21:40
13

On at least Mavericks and iTerm2, you have to hold Control, then press b (instead of holding), then hold down a directional button. This sends pretty much the same sequences as holding down Control-b with a directional button so it works.

Also, make sure to head over to keyboard settings and in shortcuts tab disable any mission control and such keyboard shortcuts you may have for Control plus a directional key.

1
  • 8
    thanks! changing the mission control/app windows bindings in Keyboard Shortcuts made the difference for me
    – sixty4bit
    Jun 11, 2015 at 20:44
8

By default Mac OS has Mission Control shortcuts bound to ctrl+arrows, and they take precedence over the Tmux controls. I do not use these shortcuts on Mac anyway, so I just turned them off in keyboard settings, and now the Tmux controls work as expected:

shortcuts

5

Open the tmux.conf file and edit it with vi:

vi ~/.tmux.conf

Insert these lines:

set -g mouse on
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on

Press "Esc" and "ZZ" to save your changes.

Now you can resize the panes using the mouse.

3
  • run tmux source-file ~/.tmux.conf then, so the config is applied. However, only the first one seems enough.
    – am.rez
    Nov 29, 2021 at 11:52
  • 1
    Ctrl+b then : to enter command, then write set -g mouse on. On a mac it helps because you want to turn the mouse off after the resize to be able to select text using it.
    – am.rez
    Nov 29, 2021 at 12:04
  • I had no idea tmux had mouse support. Mind blown! As of version 2.1 looks like set -g mouse on is all you need. stackoverflow.com/a/33336609/987968
    – colton7909
    Feb 24, 2022 at 1:40
2

I added the following key bindings to ~/.tmux.conf to resize with Ctrl + hjkl:

bind -n C-k resize-pane -U 5
bind -n C-j resize-pane -D 5
bind -n C-h resize-pane -L 5
bind -n C-l resize-pane -R 5

Then run tmux source-file ~/.tmux.conf to reload the config.

You must log in to answer this question.

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