Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Share a tmux session for pair programming with ssh


    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.