How to install and use TMUX in CentOS

Time:2020-10-28

Why use TMUX

What is TMUX? TMUX is a program to manage windows in Linux. So here’s the problem: the iterm2 MAC comes with is very easy to use. It supports both multi label and internal panel segmentation. Why use TMUX? In fact, multi label and split form are only part of the functions of TMUX. The main reason for using TMUX is that it provides a function of form group to store and recover at any time. See if the following scenarios are suitable for you:

The company’s desktop computer opened a bunch of vim and log printing windows and left work. When I got home, my inspiration burst out. I wanted to continue coding, log in to VPN, and after SSH connected to the desktop, I found that I had to open all kinds of windows again. I was in no mood for a moment… FML! At this point, you can install a TMUX on your company’s desktop. The same set of working environment, shared in multiple places.
Company server debugging program, opened a bunch of windows. I went out for a meal and found that SSH timed out. Broken pipe. Start all over again… FML! If you’ve used TMUX before, you won’t have this problem, and attach can retrieve the windows that were originally opened.

Basic concepts of TMUX

Let’s first understand a few elements of TMUX. The main elements of TMUX are divided into three layers

A collection of windows, usually used to summarize the same task. Session can have its own name, which is convenient for switching between tasks.
Window a single visible window. Windows has its own number, which is similar to the tab in iterm2.
The pane is divided into small windows, similar to the effect of C-W + V in vim.
For better understanding, the following three elements are shown in TMUX.

2016128113325068.jpg (5819×2750)

You can see that the session is always displayed in the lower left corner of TMUX, usually named after it. For example, if I am writing a blog and open a lot of windows, I will name this group of windows as blog to facilitate reconnection and switching. The window is also displayed in the form of a tab at the bottom. Each window has its own needs and is named after the currently active process. The pane is easier to understand, that is, to divide a single window into several small elements.

Installation under CentOS

First of all, I tried to install it with Yum install TMUX. Estimated no source, no TMUX found. So it is customary to find the source code installation directly.
However, there are dependencies, so you need to install libevent first.

Copy code

The code is as follows:

wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xzvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure && make
make install

Then download the source code to install TMUX

Copy code

The code is as follows:

git clone git://git.code.sf.net/p/tmux/tmux-code tmux
cd tmux
sh autogen.sh
./configure && make
make install

Two errors were reported in the process, which were relatively simple to solve. Of course, it was after consulting the data.

 
Question 1:

During this period, I encountered the execution autogen.sh An error was reported because I did not install automake. This can be solved simply by using Yum install automake.

 
Question 2:

Encountered during execution

libevent-2.0.so.5: cannot open shared object file: No such file or directory
The solution is relatively simple. Since you can’t find it, you can find another place.

Copy code

The code is as follows:

Ln – S / usr / local / lib / libevent-2.0. So. 5 / usr / lib / libevent-2.0. So. 5 ා 32-bit system
Ln – S / usr / local / lib / libevent-2.0. So. 5 / usr / lib64 / libevent-2.0. So. 5 ා 64 bit system

Using and shortcut keys

Enter TMUX mode directly from the command line.

TMUX mainly includes windows window operation and pane operation. I feel that windows is of little significance to me (not to say that the windows mode does not apply to the scene), so here I will mainly talk about the pan operation.

 
Shortcut key

TMUX shortcut keys must first press C-B (ctrl-b). Then press the table below to achieve the corresponding effect.

 
Session and other related shortcut keys

Shortcut key function
C-z Shut down TMUX
: Enter TMUX command line mode
? Lists all shortcut keys
t Display time
d Exit the current TMUX client and run TMUX in the background
$ Rename the current session
s Switch session displays all sessions and switches to a session
( Switch session switch to the previous session
) Switch session switch to the next session
L Switch session to the previous active session

Windows related shortcut keys

Shortcut key function
c Add a window
& Exit the current window
, Rename the current window
l Jump to the previous window
i Display the current window information
w Switch windows display all windows and switch windows
0 to 9 Switch the window to the corresponding numbered window
p Switch the previous window of window
n Switch window to the next window
Switch window to input window
f Switch window to the search window
Space Change the current window under the pan layout

Pan related shortcut keys

Shortcut key function
! Remove the current pane from window
Change the current pan into two panes
% Change the current pane into two panes
x Close the current pane
q Displays the index of the pane
z Maximize or restore the current pane
{ Switch positions with the previous pane
} Switch positions with the next pan
o Switch the pane to the next one
; Switch the pane to the previous one
Up, Down Left, Right

Switch panes use the direction keys to switch to the corresponding direction of the pane

There may be some shortcut keys in and out, if you can remind. In addition, I don’t think there are enough shortcut keys to understand. In addition, I don’t think there are enough shortcut keys to understand. Comparing TMUX is just a helper tool, there is no need to be so attentive on it. Bold is more practical.

TMUX does not interrupt the session mode. Every time you connect back, you can quickly connect to the environment you ended last time. Moreover, multiple panes are also very suitable for opening and monitoring multiple services.

2016128112818661.png (1842×989)

Recommended Today

Layout of angular material (2): layout container

Layout container Layout and container Using thelayoutDirective to specify the layout direction for its child elements: arrange horizontally(layout=”row”)Or vertically(layout=”column”)。 Note that if thelayoutInstruction has no value, thenrowIs the default layout direction. row: items arranged horizontally.max-height = 100%andmax-widthIs the width of the item in the container. column: items arranged vertically.max-width = 100%andmax-heightIs the height of the […]