Deprecated Behaviour

The inane, sometimes insane, ramblings from the mind of Brenton Alker.

Share Tmux Windows Across Sessions

When working in a terminal (the vast majority of the time) I run the terminal multiplexer tmux, with one session for each project I am currently working on. I like to have a window for my IRC client in every session, so I can keep an eye on it. The best way to do this is to share the tmux window across multiple tmux sessions.

To perform this setup, we can create a new session for “shared” applications, opening irssi in a window named “irc”. Either manually create the windows and open the applications in them, or, if you’re lazy and use the same setup regularly. Script it, something like so:

tmux new-session -s shared "tmux new-window -n irc irssi"

You can use the automatically-assigned window names, but since I’m referencing them across sessions, I feel explicitly naming them (with the -n) is more robust.

Once the applications are running, we can link the windows to the working session using tmux’s link-window command, which has the basic form:

tmux link-window -s <src-window> -t <dst-window>

Any time a tmux command requires a reference to a window, we can provide an absolute reference to any window in any session using the session:window format where session is the name of the session and window is the name (or number) of the window in that session.

Using this, we can use the link-window our “shared:irc” window to index “9” in the current session. Which looks like:

tmux link-window -s shared:irc -t 9

The target parameter is optional, without it the window will be placed in the next available index, but I like to place it at the end of the list so they don’t get in the way of my “real work”.