How to set up pair programming using tmux
Learn how to use tmux for remote pair programming on macOS and Linux over Meshnet.
Introduction
Command-line interface (CLI) text editors, such as Vim, are widely used by developers. CLI development environments can offer many advantages over their counterparts, such as the ease of initial configuration, the ability to interact with other CLI utilities, and the convenience of working with remote servers. All of these factors can contribute to a large improvement in productivity.
A popular open-source terminal multiplexer tmux is often used for CLI work. This tool can be beneficial on servers and devices that have only a single terminal interface. You can create several sessions for different workflows, for example:
Interacting with Docker container shells
Pair programming
Continuous file transfers
By incorporating Meshnet, devices from different networks can be connected to a single, secure virtual network. With this configuration, the developers' devices can be easily reached using remote access methods, such as secure shell (SSH). As a result, a shared tmux session between remote devices can be established.
This article contains instructions on how to set up tmux on macOS and Linux devices and initiate a shared terminal session using Meshnet.
Before you begin
To use tmux for pair programming, your system must allow SSH connections from other devices in your Meshnet. See the Enable SSH access section of the "How to access remote systems over Meshnet using SSH" article for instructions on how to enable SSH on your devices.
Installing tmux
You can install tmux on Linux by running the following command in the terminal:
Connecting via SSH
To participate in the shared session, you have to access the host device from your client device via SSH.
Open Command Prompt (on Windows) or Terminal (on Linux or macOS).
Enter the following command, where
<username>
is your remote PC account name and<server>
is the Nord name or Meshnet IP of the computer you want to access:Example
or
The first time you connect, you will be asked to verify the authenticity of the server. This message is displayed to make sure you are connecting to the correct remote server. Type
yes
to continue, as shown:Enter the password for the specified username.
The SSH connection will be established, and you will have access to the host device’s terminal. However, for now, both terminal instances work separately.
Controlling tmux
With tmux installed and SSH configured, you can start using the terminal-sharing capabilities of tmux.
Start a shared session
On the host device’s terminal, run the following command, where <SessionName>
is any name for the session:
Example:
The terminal window will update and clear any commands that were entered previously.
Join a shared session
After accessing the host via SSH, run the following command, replacing <SessionName>
with the name of the active tmux session:
Example
The terminal window will update, and you will be connected to the tmux shared session.
While you are attached to the tmux session, the terminal will update on both devices in real time. This means that any input on one machine will be seen on the other.
Detach from a shared session
If you wish to disconnect from the tmux session without fully stopping it, you can do so by pressing Ctrl + B and D on your keyboard or running:
Stop a shared session
If you wish to fully stop the tmux session, you can use the following command:
For additional tmux commands and options, refer to the tmux manual page.
You may now securely collaborate using only one terminal instance between two or more remote devices.
Last updated