86

screen has a Ctrl-a,Ctrl-a to switch between two latest windows?

How to do it in tmux?

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
kev
  • 12,462
  • 13
  • 59
  • 72
  • that's easily answered yourself question. Another one — which is a way harder to answer is *how to switch to the last window* – poige May 22 '20 at 05:45

4 Answers4

132

To do this in tmux, you do

Ctrl-Bl

(that is an 'L'). This assumes you have left Ctrl-B as your activation key.

If you want to use the same keypresses as screen, then add the following to your ~/.tmux.conf:

set-option -g prefix C-a
bind-key C-a last-window

The first sets Ctrl-A as your activation key, the second says Ctrl-A after activation should go to the last window.

Paul
  • 59,223
  • 18
  • 147
  • 168
5

Paul's answer is correct, but it seems to leave you without a way to type ^A.

See this thread for details, but essentially you can do this to get a C-a (^A) if you need one:

bind-key v send-prefix

Now if you type C-a v you'll get a ^A.

fbicknel
  • 211
  • 3
  • 6
5

To follow on to fbicknel and Paul:

you can

bind-key C-a last-window
bind-key a send-prefix

which will let you use a screen-like "ctrl-a a" to insert a 'ctrl a'

CyberPathogen
  • 51
  • 1
  • 1
1

I added:
bind-key l last-window
Into my tmux config file which by default is at ~/.tmux.conf.
Reload tmux, switch windows at least once and press:
ctrl+B (default prefix) + l (lower-case L) works like a charm!