Tmux's introduction:
Tmux is a good terminal reuse software, even if the non-normal drop line, but also to ensure that the current task to run, this is particularly useful for remote SSH access, the network is not a bad situation can still ensure that the work site is not lost, in addition, Tmux fully use the Keyboard control window to achieve the window switching function.
Tmux two main functions:
Split (cut) window, you can open multiple terminals under one terminal, or you can split the current screen in a variety of ways, that is, you can open multiple terminals with a smaller display range at the same time.
In the use of SSH environment, to avoid network instability, resulting in the loss of the work site. Imagine the following scenario when you execute a command and the SSH connection is broken due to network instability. At this point, you don't know if the previous command was successful. If you open a lot of files at this time, into a deeper directory, due to network instability, SSH connection disconnected. After reconnecting, you have to reopen those files and enter that deep directory. If the use of Tmux, reconnect later, you can directly back to the original work environment, not only improve the efficiency, but also reduce the risk, increased security.
Here's where Tmux goes beyond screen:
Screen projects have largely terminated, and there are a lot of problems in the code;
Tmux is an active project, and its code base is frequently updated;
Tmux is using a real client/server model, and screen just simulates the behavior of this model;
Tmux supports both Emacs and Vim shortcuts;
Tmux supports automatic renaming of Windows;
Tmux can be highly scripted;
Tmux window Segmentation function is more advanced;
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7F/CA/wKiom1csfJGB8N76AACaR0SYnxk116.jpg "title=" Tmux.jpg "alt=" Wkiom1csfjgb8n76aacar0synxk116.jpg "/>
PS: A session can contain multiple windows, and a window can contain multiple panes (Pane).
One, compile and install Tmux
1, first install the dependency package libevent-2.0.21-stable.tar.gz
# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# Tar XF libevent-2.0.21-stable.tar.gz
# CD Libevent-2.0.21-stable
#./configure
# Make && make install
2, compile and install Tmux
# git clone https://github.com/tmux/tmux.git
# CD Tmux
# sh autogen.sh
#./configure--prefix=/usr/lcoal/tmux
# Make && make install
3, provide header file
# ln-sv/usr/local/lib/libevent-2.0.so.5/usr/lib64/libevent-2.0.so.5
# ldconfig-v
4. Add the Tmux script path to Path
# vim/etc/profile.d/tmux.sh
Export path= $PATH:/usr/local/tmux/bin
# Source/etc/profile
5. Add the Tmux command Man document path to the Manpath
# Vim/etc/man.config
Manpath/usr/local/tmux/share/man
6, Configuration Tmux
# Vim ~/.tmux.conf
# Set TMUX command activation button for CTRL + A
SET-OPTION-G prefix c-a
Unbind-key C-b
Bind-key c-a Send-prefix
# Set Default shell
Set-option-g default-shell/bin/zsh
# Settings window to automatically adjust index
Set-g Renumber-windows on
# Set Window start
Set-option-g Base-index 1 # # # # The initial Sequence number of the window, default is 0, here is set to 1
Set-option-g Status-keys VI # # #操作状态栏时的默认键盘布局; can be set to VI or Emacs
Set-option-g Display-time 5000 # # # # # # # # # The duration of the message; set enough time to avoid seeing the hint in milliseconds
Set-option-g Repeat-time # # # #控制台激活后的持续时间; Set the appropriate time to avoid activating the console for each operation, in milliseconds
# History
Set-option-g history-limit 4096
# set Copy mode, space start Select, enter End copy
Set-window-option-g Mode-keys VI
# Open Status-bar uft-8 support
Set-option-g Status-utf8 on # # # Open status bar UTF-8 support
# set pane foreground color
Set-g PANE-BORDER-FG Green
# set Pane background color
Set-g PANE-BORDER-BG Black
# set terminal color to 256 colors
Set-g default-terminal "Screen-256color"
# set Window list color
Setw-g WINDOW-STATUS-FG Cyan
Setw-g WINDOW-STATUS-BG Default
Setw-g Window-status-attr Dim
# Toggle Panes
Bind h Select-pane-l
Bind J Select-pane-d
Bind K Select-pane-u
Bind L Select-pane-r
Bind-key c-l Last-pane
# #Status Bar
#colors
Set-g STATUS-BG Black
Set-g STATUS-FG White
#开启status-bar uft-8 Support
Set-g Status-utf8 on
# # Slignment
Set-option-g Status-justify Centre
# # spot at left
Set-option-g status-left ' #[bg=black,fg=green][#[fg=cyan] #S #[fg=green]] '
Set-option-g Status-left-length 20
# # Window
Setw-g Automatic-rename on
Set-window-option-g Window-status-format ' #[dim] #I: #[default] #W #[fg=grey,dim] '
# # spot at right
Set-g status-right ' #[fg=green][#[fg=cyan]%y-%m-%d#[fg=green]] '
Set-option-g Status-right-length 50
# # Resize Pane
Bind-r ^k resizep-u 10
Bind-r ^j resizep-d 10
Bind-r ^h resizep-l 10
Bind-r ^l Resizep-r 10
# set R key to load config file and prompt information
Bind r source-file ~/.tmux.conf \; Display "config file has been reloaded! "
# Setting the window name cannot be modified
Set-option-g Allow-rename off
# Default name when setting startup window
Bind-key c new-window-n ' zsh '
# Open Window Event prompt
Setw-g monitor-activity on
Set-g visual-activity on
Set-window-option-g Mode-keys VI # # # # # # # default keyboard layout in copy mode, can be set to VI or Emacs
Set-window-option-g UTF8 on # # # open Window UTF-8 support
# shortcut keys for copy and paste mode
Bind y Copy-mode
Bind C-y Copy-mode
Bind P Paste-buffer
Bind C-p Paste-buffer
After pressing CTRL-A, the following shortcut keys are as follows:
Basis
? Get help information
Session Management
s lists all sessions
$ rename the current session
D disconnecting the current session
Window Management
C Create a new window
, rename the current window
W List all Windows
% Horizontal Split window
The vertical split window
n Select the next window
P Select Previous Window
0~9 Select the corresponding window for 0~9
Pane Management
% Create a horizontal pane
"Create a vertical pane
H move the cursor into the left pane
J move the cursor into the lower pane
L MOVE the cursor into the right pane
K Move the cursor in the upper pane
Q Display the number of the pane
o Switch between panes
Swap locations with the next pane
{Swap location with previous pane
! Display the current pane in a new window
X Close the current pane
Other
T displays the time in the current pane
This article is from "Luo Chen's blog" blog, please be sure to keep this source http://luochen2015.blog.51cto.com/9772274/1770894
Initial knowledge Tmux---Compile and install Tmux