I usually work with 2 monitors that are not quite vertically aligned (I have a benchtop power supply under my left monitor), but I want to have 4 terminal windows side-by side on my screens which I can cycle through easily, like so:

enter image description here

This arrangement makes me very sad because I can't easily cycle through all 4 in a sane way using only my keyboard (alt-tab doesn't cut it for me because it does not keep the "ordering" of all 4 windows - if I repeatedly press alt-tab, it just bounces between my 2 least-recently-used windows)

Is there a way to get tmux to generate a second x-window so that I can have 2 x-windows, with each one having 2 tmux panes inside of it?

  • 1
    So your problem is (was) that you have your windows tiled across two monitors and alt+tab cycles between the two most recent windows instead of all four? This seems like a job for a tiling window manager. Have you tried any? There are plenty of them. awesome, i3, wmii, xmonad, and dwm are among the best. Though for your purposes, I would suggest i3(1), since it is simple to pick up (reading the config file teaches you both the controls and the configuration basics) and is tailored to multi-monitor (xinerama/xrandr) setups. Apr 28, 2017 at 7:11
  • I tried i3 and I absolutely loved it, but it caused crashes on my ubuntu setup about once an hour :( It also didn't play nice with my monitors for some reason.
    – John M
    Apr 28, 2017 at 17:52
  • really? How about the other ones? wmii and xmonad would be the next on my suggestions queue, since they are also "fancy" tiling wms, followed by dwm (my personal favorite). While not as extensively featured as i3, they handle multiple monitors​ pretty elegantly IMO. Apr 28, 2017 at 18:26
  • FWIW: I have been using xmonad for work for 20+ years and during that time it has crashed zero times. Nov 14, 2023 at 4:46

3 Answers 3


tmux allows you to create "session groups" - multiple sessions that can all attach to the same set of windows.

(With thanks to https://gist.github.com/chakrit/5004006 :)

In the left terminal, create a new session+window group.

tmux new-session -s left

Split it into panes as usual.

:split-window -v

In the other (right-hand) terminal, connect to that existing window group. You're going to have to give it the old name to connect to, and its own session name to distinguish it.

tmux new-session -t left -s right

In that session, create another window and split

:split-window -h

You can now see all the (tmux) windows in each (terminal) window, but the view in each is independent of the other.

To switch from one to the other (without using your window manager's own shortcuts), you could use eg. xdotool.

xdotool search --name 'left:0:' windowactivate
xdotool search --name 'right:1:' windowactivate

These assume that you have enabled tmux's set-titles option, in order to give the terminal a searchable name; and that you're only using one tmux window (set of panes) in each.

  • To complete this, I need a script that reliably queries the current pane and advances to the "next" one, using the "activate window" command when appropriate. But I haven't yet figured out how to do that - I think it's going to need some additional data store outside of what's available to tmux.
    – JigglyNaga
    Jun 29, 2016 at 7:23
  • Note you might need to turn on aggressive resize (setw -g aggressive-resize on), otherwise the windows won't fit the full screen
    – dgmora
    Dec 15, 2016 at 11:09

You will want to start a separate tmux session in each terminal, and then split each session's single tmux window into two panes vertically.

So, in each terminal:

$ tmux new-session \; split-window -h

Or shorter, in each terminal:

$ tmux new \; splitw -h

You need two sessions, because with one session, the two terminals would always be synchronized and show the same tmux window.

Then use your desktop's shortcuts to swap between the two terminals.

Personally, I would have gone with one single monitor, one tmux session and two (or however many) split tmux windows "behind" each other, and swap between them with Ctrlb-n, but that's a matter of taste.

$ tmux new \; splitw -h \; neww \; splitw -h

Can you not do the low-tech method of resizing one terminal (by dragging edges) to cover both monitors, such that the centre divider is at the boundary of the two monitors?

  • 1
    This doesn't work if both monitors are different heights, or if you're using OS X.
    – James
    Nov 4, 2016 at 14:39

You must log in to answer this question.

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