tmux

Tmux is an excellent terminal reuse software, similar to GNU Screen, but comes from OpenBSD and is licensed by BSD.

Supplementary instructions

The most intuitive benefit of using it is that after logging in to the remote host through a terminal and running tmux, you can open multiple consoles without "wasting" extra terminals to connect to the remote host;

Function

Install

# In Mac OS, install via brew
brew install tmux
# Direct apt-get installation under ubuntu version
sudo apt-get install tmux
# Install directly with yum under centos7 version
yum install -y tmux

# centos6 version needs to be compiled and installed
yum install libevent libevent-devel ncurses-devel
tar -zvxf tmux-2.3.tar.gz # (Download in advance: wget https://github.com/tmux/tmux/releases/download/2.3/tmux-2.3.tar.gz)
cd tmux-2.3
./configure
make && make install

Instructions for using shortcut keys

Ctrl+bActivate the console; the following keys take effect at this time

System operation

?List all shortcut keys; press q to return
dDetach from the current session; this allows you to temporarily return to the Shell interface and enter tmux attach to re-enter the previous session
DSelect the session to leave; use it when multiple sessions are open at the same time
Ctrl+zSuspend current session
rForce redraw of undetached sessions
sSelect and switch sessions; used when multiple sessions are open at the same time
:Enter command line mode; you can enter supported commands at this time, such as kill-server to shut down the server
[Enter copy mode; the operation at this time is the same as vi/emacs, press q/Esc to exit
~List the prompt information cache; it contains various prompt information previously returned by tmux

Window operations

cCreate new window
&Close current window
Numeric keysSwitch to the specified window
pSwitch to the previous window
nSwitch to next window
lSwitch between the front and rear windows
wSwitch windows via window list
,Rename the current window; this makes it easier to identify
.Modify the current window number; equivalent to window reordering
fFind the specified text in all windows

Panel operation

Divide the current panel into two equal parts: upper and lower
%Divide the current panel into two equal parts: left and right
xClose the current panel
!Place the current panel in a new window; that is, create a new window that contains only the current panel
Ctrl+arrow keysMove the edge in units of 1 cell to resize the current panel
Alt+arrow keysMove the edge in units of 5 cells to resize the current panel
SpaceCycle through the preset panel layouts; including even-horizontal, even-vertical, main-horizontal, main-vertical, tiled
qDisplay panel number
oSelect the next panel in the current window
Arrow keysMove cursor to select panel
{Displace current panel forward
}Displace current panel backward
Alt+oRotate the panel of the current window counterclockwise
Ctrl+oRotate the panel of the current window clockwise
ctrl+b ? # Show shortcut key help
ctrl+b spacebar # Use the next built-in layout. This is very interesting. When using multiple screens, using this will display multiple screens vertically.
ctrl+b ! # Change the current window into a new window
ctrl+b " #Model split window
ctrl+b % # Separate windows vertically
ctrl+b q # Display the number of the separated window
ctrl+b o # Jump to the next split window. Switch between multiple screens
ctrl+b up and down keys # Previous and next separated windows
ctrl+b C-arrow keys # Adjust the size of the split window
ctrl+b & # Exit the current tmux after confirmation
ctrl+b [ # Copy mode, that is, move the current screen to the previous position, and all other windows will be moved forward by one.
ctrl+b c # Create a new window
ctrl+b n # Select the next window
ctrl+b l #Last used window
ctrl+b p # Select the previous window
ctrl+b w # Display and select windows in menu mode
ctrl+b s # Display and select sessions in menu mode. This is commonly used. You can choose which tmux to enter.
ctrl+b t # Display the clock. Then press the enter key to return to the shell terminal state.
ctrl+b d # Detach from the current session; this can temporarily return to the Shell interface, and enter tmux attach to re-enter the previous session.

References