Share a tmux session for pair programming with ssh

Bonnie Eisenman
InstructorBonnie Eisenman
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 6 years ago

By using ssh, you can share a tmux session, making pair programming much easier. We'll learn how to share a tmux session with another user.

[00:00] One of the really neat things that you can use tmux for is pair programing. You can see right here I have two terminal windows open. They're both SSH into the same server.

[00:09] I'm using a simple DigitalOcean Droplet. You can of course set up SSH with your pair programmer however you want, whether that's with another server or with one of your laptops, whichever works best for you.

[00:21] The neat thing here is that in one of these windows, we can type tmux new session -s pair, and it'll launch a tmux session. So far, so good. This is a pretty ordinary thing to do.

[00:38] If I go into the other window, I can run tmux ls, and I can see that there is a tmux session here, which I can also attach to. I'm going to type tmux a, which is a shortcut for attach, -t pair.

[00:52] Now both of these windows, they are separate SSH sessions, and they are attached to the same tmux session. Commands, the pane setup, all of that stuff will be reflected in both. For example, I can do a pane split with Ctrl-b+%, and we see that both sessions reflect the split.

[01:13] Let's go back down to one pane. I'm going to do Ctrl-d to close that extra one. Let's go into vim.

[01:21] This is where it starts to get really cool for pair programing. I can do the quick brown fox jumped over the lazy dog. Obviously, you're going to be wanting to write something a little bit more substantial.

[01:34] The cool thing here is that this happens with barely any lag, and not only do you get to see my code update live, you also get to follow my cursor. You can see how I'm navigating and all of that.

[01:45] Again, this doesn't require any fancy configurations or changes to how you use tmux. You both just have to be sharing the same session.