How to set up pair programming using tmux
Learn how to use tmux for remote pair programming on macOS and Linux over Meshnet.
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.
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.
Linux
macOS
You can install tmux on Linux by running the following command in the terminal:
sudo apt install tmux -y
- 1.Open Terminal.
- 2.Enter the following command:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- 3.Follow the on-screen instructions to finish the installation.
- 4.install tmux by running the following command:brew install tmux
To participate in the shared session, you have to access the host device from your client device via SSH.
- 1.Open Command Prompt (on Windows) or Terminal (on Linux or macOS).
- 2.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:ssh <username>@<server>Exampleor - 3.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: - 4.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.
With tmux installed and SSH configured, you can start using the terminal-sharing capabilities of tmux.
On the host device’s terminal, run the following command, where
<SessionName>
is any name for the session:tmux new -s <SessionName>
Example:
tmux new -s MeshnetSession
The terminal window will update and clear any commands that were entered previously.
After accessing the host via SSH, run the following command, replacing
<SessionName>
with the name of the active tmux session:tmux attach -t <SessionName>
Example
tmux attach -t MeshnetSession
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.
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:
tmux detach
If you wish to fully stop the tmux session, you can use the following command:
tmux kill-session
You may now securely collaborate using only one terminal instance between two or more remote devices.