Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Share a tmux session for pair programming with ssh

    Bonnie EisenmanBonnie Eisenman

    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.

    tmuxtmux
    Code

    Code

    Become a Member to view code

    You must be a 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
    Transcript

    Transcript

    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.

    Discuss

    Discuss