Why Tmux is needed?
During your daily work, it’s quite common to open several windows to accomplish your tasks.
If you don’t use Tmux alike screen manager, it will be totally a nightmare.
Following demonstrates a typical scene. You open a window to view the code project, and another one to build it. Apart from them, you can also open some other auxiliary windows, e.g, htop window, to watch the real-time CPU performance.
What’s more, if you are a DevOps engineer who should ssh to remote machine to do some developments, you will find Tmux useful. It offers you the mechanism to close the session temporarily without any concern, and reattach to it in an easy manner. Tmux will manage the sessions until your next access.
There are definitely other alternatives to Tmux, e.g, screen, and you can choose anyone as you like.
In this post, we mainly describe our settings based on Tmux.
Setup
Install Tmux:
sudo apt-get install tmux
Download the config repo to your home directory:
git clone --recursive git@github.com:sunbingfeng/tmux-config.git $HOME/.tmux
Set it as the default tmux configuration:
ln -s ~/.tmux/.tmux.conf ~/.tmux.conf
Usage
The default prefix/leader key is Control+o, and you can change it to your preference.
Basic:
-
tmuxto create a new tmux session -
tmux ato attach to an existed session - The prefix key must be typed before any commands
-
Control+othen?to bring up list of key mappings
Window managements:
-
Control+othensto show list of windows available -
Control+othenfto search window through keywords -
Control+othen,to rename current window -
Control+othen&to kill current window -
Control+othencto create new window -
Control+othennto goto the next window -
Control+othenpto goto the previous window -
Control+othenControl+aswitch between current and last window -
Control+othen[0-9]to goto the numbered window
Pane managements:
-
Control+othenvto split horizontally -
Control+othenbto split vertically -
Control+othen;to switch between current and last pane -
Control+othenh,j,k,lto move left, down, up, right respectively as vim does -
Control+othenzto maximum/restore current pane -
Control+othenxto close current pane
Copy&Paste:
We use xclip be default, so you should install it through:
sudo apt-get install xclip
-
Control+othen[to enter copy mode - Press
vto select blocks, orVto select multiple lines, and thenyto copy it to clipboard - Goto where you want to paste, and press
ito enter edit mode. PressControl+othen]to paste.

Comments