63

Normally, I can jump to a window in tmux using Prefix-N, where N is my window number.

Unfortunately, if N is number of like 10, it will just jump to window 1.

How can I jump to Window 10 instead?

merlin2011
  • 71,677
  • 44
  • 195
  • 329

1 Answers1

95

There are two straightforward options (let C-b represent the prefix key):

  1. Bring up a prompt in which to enter a specific window index with C-b ' (this is a default key binding). Press enter after inputting the desired index.
  2. Interactively select the window you want from a list with C-b w (also a default key binding). In this list, windows are assigned a character in order from 0 to 9 and then from a onward. Press a character to jump to the corresponding window or use the arrow keys to highlight one and press enter.

Although option 2 is fewer keystrokes (using the characters), it's arguably less elegant than option 1. First, the window list completely obscures the current pane; second, indices are assigned to windows based on their order, meaning that the index in the list may sometimes differ from the index displayed in the window titles (such as when there are gaps in the window numbering).

If you're looking for the least intrusive and most analogous (compared to C-b N) solution, option 1 is probably your best bet.

nklauza
  • 1,501
  • 1
  • 12
  • 12
  • 1
    I agree, Option 1 is better, but I'm glad you listed both. – merlin2011 Aug 16 '14 at 02:46
  • 10
    Nice, didn't know about `prefix + '` –  Aug 19 '14 at 21:13
  • what about switching to *pane* 10+? – mylord Oct 01 '16 at 10:55
  • @mylord In vanilla tmux, `C-b :select-pane -t M` switches to pane `M`. This can be shortened by adding a key binding to .tmux.conf (let `/` represent the key to be bound): `bind / command-prompt -I "select-pane -t "`. To more closely imitate option 1 above, add the following line instead, which hides the raw command text behind a custom prompt: `bind / command-prompt -p "pane index" "select-pane -t %1"`. For either binding, simply type `C-b / M` followed by enter to switch to pane `M`. – nklauza Nov 20 '16 at 22:45
  • pressing "C-w" then "a" doesnt work for me! on a mac. what could be the reason? – Paschalis Oct 29 '18 at 08:43
  • I'm using tmux 2.7 and the window list (produced by -w) shows that I need to press M-a, M-b, etc. for windows above 9. I am also on a Mac and I cannot for the life of me figure out how to use the Meta key. I would prefer to simply type the letters a, b, etc. Not sure why it wants -a in the first place. – tanager Nov 15 '18 at 16:10
  • @tanager I think `esc` is the default Meta key. If you're using the native app, you can change it to `option` in the Terminal preferences. – nklauza Nov 16 '18 at 03:41
  • @Paschalis It's been a while since I authored my answer, but I believe it worked with some previous version of tmux as I don't recall needing to use the Meta key. I may be misremembering, but I should update it regardless. Anyway, does the window list show `M-a` for the 10th window or just `a`? – nklauza Nov 16 '18 at 03:52
  • 1
    @nklauza Yes, I've read that `esc` is the Meta key for Mac, but I can't figure out how to use it. If I try to type `esc-a` the menu just disappears. If I try `esc` followed by `a` the menu disappears before I get to `a`. If I type and hold `a` and then type `esc` the menu disappears. Could it be related to the fact that I use 'vi' keys for menu navigation? – tanager Nov 16 '18 at 17:51
  • 1
    @Paschalis I discovered that version 2.5 of tmux shows a, b, etc. for the higher-indexed items in the list, but 2.7+ shows M-a, M-b, etc. I have no idea why anyone would make this change. Seems much less friendly, especially given my inability to get the Meta key to work. – tanager Nov 16 '18 at 17:52
  • 1
    @tanager I also use vi keys, so I don't think that's it. After opening the window list, hold the `esc` key and then tap `a`. That should work as long as `esc` truly is your Meta key, i.e. assuming your Meta key has not been remapped in a config file or something. – nklauza Nov 17 '18 at 03:51
  • I cannot hold the `esc` key. As soon as I press it, the menu goes away, whether or not I hold it. – tanager Nov 19 '18 at 16:15