Commits and Rebases
Pair programming is a well-known technique to avoid bugs by doubling the amount of eyeballs on a piece of code, to increase the quality of code by doubling the amount of brains thinking about a problem, and to make programming more social and collaborative.
Its use is high and increasing in the industry, especially pairing a senior developer with a junior developer to help the junior understand the tools, the code and the workflow of the team.
It's possible to do pair programming in Linux when working remotely by using terminal multiplexers (if you are using a text-based editor like
emacs ). The two most famous terminal multiplexers are
tmux , and I'm going to show you how to do pair programming using
Before we start, a short introduction to the concepts so the tutorial will make sense:
tmux uses a socket to communicate all of its sessions. This socket can simply be a file (I'm going to use a file here) and anyone with read and write permissions to this socket can participate in the session.
Step 1: Create the needed users.
# adduser user1 # adduser user2
Step 2: Create a common group for everyone.
This group is going to have all users allowed to participate in the session and the socket will be assigned to it.
# groupadd pair # usermod -a -G pair user1 user2
Step 3: Create the session on the socket.
# apt-get -y install tmux $ tmux -S /tmp/pair.sock new -s pair
It is advisable to create the socket inside /tmp to avoid cluttering the system and data leakage.
Step 4: Grant read and write access to the socket.
$ chgrp pair /tmp/pair.sock
Step 5: Tell people to join the session.
$ tmux -S /tmp/pair.sock attach -t pair
That's it. Whatever anyone sees in their terminal, everyone else will see the same. Enjoy!