Skip to content
Lucas Caton

Pair programming with tmux

Set up tmux for pair programming in a remote environment

Lucas Caton

Lucas Caton

@lucascaton
Pair programming is a technique where two developers work together on the same task. One is the "driver", typing and interacting with the code, while the other is the "navigator", reviewing the code and suggesting improvements. This method can significantly improve code quality and encourage learning.
When working remotely, keeping both developers on the same page can be challenging. However, tmux - a terminal multiplexer - makes this easier by allowing multiple users to share a session, even across different locations.
tmux
I'll explore how to set up tmux for pair programming, which involves two steps:
  • Both users accessing the same server or system
  • The server setup (for the driver) and the client setup (for the navigator)

Server setup

First, the "driver" needs to set up the tmux session. This requires access to a shared system or server where both developers can connect. On the server, run the following commands:
bash
# -2` flag ensures that tmux uses 256-color support
# `-S` specifies a UNIX socket, so others can connect to this session
tmux -2 -S /tmp/pair new-session -s PairProgramming

# Ensure the correct permissions for other users to connect:
chmod 777 /tmp/pair
This command creates a new tmux session called PairProgramming but you can call it whatever you'd like.

Client setup

On the client (the "navigator"), run this command to attach to the tmux session:
bash
tmux -2 -S /tmp/pair attach-session -t PairProgramming
The navigator will now be able to see the same terminal session as the driver. Both users can interact with the session in real-time.

Alternatives to consider

If you're working in different environments or need more advanced features (like a graphical interface or more robust collaborative tools), consider using other solutions such as VS Code's Live Share feature or cloud-based IDEs.

Post updated at 02/03/2025, 10:00:00

💬 Comments are temporarily disabled. Sorry for the inconvenience.