How to Install and Configure Tmux for Linux

If you constantly switch between terminals and can’t find the right window when you need it, consider using a multiplexer. These are programs that allow users to run multiple terminal sessions inside a single window.

Tmux is a popular multiplexer that offers a lot of great features. It makes it easy to run different applications in separate sessions and switch between them easily.

How to Install Tmux in Linux

This tutorial introduces how to install and configure Tmux for Linux machines. Activate a Terminal and use the appropriate installation method for your system.

On Debian-based distributions:

sudo install tmux

On CentOS/REHL:

yum install tmux

To install tmux on Arch Linux:

pacman -S tmux

Once the installation is done, launch a Terminal and type tmux to start a new Tmux session. This command will start a new session inside a window and start the shell. The status bar at the bottom shows information about your current session.

tmux

Using Tmux for the first time

Tmux has many concepts like sessions, windows, panes and hotkeys. So beginners often find it very intimidating. However, once you have a good understanding of Tmux, you will feel the effectiveness of this tool much more clearly.

A Tmux session defines the task at hand. Windows allows users to perform different operations within a session. Panels, on the other hand, will allow you to work with separate views within the window.

See more:  How to specify a CPU core in Linux with Taskset

You can manage all of this via hotkeys in Tmux, a combination of the Tmux prefix followed by a specific key. The default prefix is Ctrl + REMOVE.

How to manage sessions in Tmux

Tmux can handle multiple sessions at the same time. This allows developers to switch between different projects easily. You can also create a new session anytime you want.

Refer to the article: How to manage and restore Tmux sessions in Linux for more details.

How to manage windows in Tmux

The Tmux window spans the entire screen and can be divided into multiple panes. Each of these panes will act as a separate virtual Terminal. You can create a new tmux window with Ctrl + B c.

Use Ctrl + B , to rename your Tmux window. It will call the Tmux interpreter. Enter the new window name here.

Rename the Tmux window
Rename the Tmux window

Tmux makes switching between different windows easy. Enter the Tmux prefix, followed by the window number. For example, you can quickly switch to the second window with Ctrl + B 2.

You can also swap Tmux windows. To do this, invoke the interpreter by typing Ctrl + B : and enter the following information.

: swap-window -s 1 -t 3

This command switches the first and third windows. You can delete a window once done using Ctrl + B &.

Switch window
Switch window

How to manage panes in Tmux

Up to this point, the article has covered how to use sessions and windows in Tmux. However, things get really interesting once you start using panes. Panels are essentially virtual terminals that run inside windows. Users can use them to run several instances of Terminal from a single Tmux window.

See more:  11 best Linux password managers

You can create horizontal and vertical panes in Tmux. Type Ctrl + B “ to split the view horizontally.

Split the view horizontally
Split the view horizontally

This will split the current window horizontally and open a Terminal in a new window. Use Ctrl + B % to start a vertical pane.

Start a vertical pane
Start a vertical pane

You can create horizontal and vertical panes at the same time. Use hotkey Ctrl + B o to switch between panes.

Changing the zoom level of a pane allows the user to hide all other panes. This feature comes in very handy when you need to focus on a specific task. Use Ctrl + B z to switch panes. You can close the current pane at any time using hotkey Ctrl + B x.

Close current pane pane
Close current pane pane

How to Configure Tmux in Linux

You can configure almost any aspect of a Tmux installation. However, the article recommends that you start with the basics and move on to more advanced options later.

Configuring Tmux is done by tweaking the file ~/.tmux.conf. Use your favorite Linux text editor to edit this file.

vim ~/.tmux.conf

Let’s look at some basic configurations. For example, you can change the Tmux prefix from Ctrl + REMOVE Fort Ctrl + A by adding below line in file tmux.conf.

set -g prefix C-a
unbind C-b

Unbinding the default key allows you to reassign it to another command. So the second line is an example, nothing is required here.

Basic configuration
Basic configuration

You can also change the base index of windows and panes from 0 Fort first, which is very intuitive for users who are not comfortable with 0-based indexes.

set -g base-index 1 # starts window numbering from 1
set -g pane-base-index 1 # starts pane numbering from 1

Since Tmux is a Terminal-driven tool, it does not support mouse functions. However, you can easily enable mouse support for Tmux by adding the file below to your configuration.

set -g mouse on

Hope you are succesful.

See more:  The dd command in Linux

Source link: How to Install and Configure Tmux for Linux
– https://techtipsnreview.com/

, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *