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:
-
tmux
to create a new tmux session -
tmux a
to attach to an existed session - The prefix key must be typed before any commands
-
Control+o
then?
to bring up list of key mappings
Window managements:
-
Control+o
thens
to show list of windows available -
Control+o
thenf
to search window through keywords -
Control+o
then,
to rename current window -
Control+o
then&
to kill current window -
Control+o
thenc
to create new window -
Control+o
thenn
to goto the next window -
Control+o
thenp
to goto the previous window -
Control+o
thenControl+a
switch between current and last window -
Control+o
then[0-9]
to goto the numbered window
Pane managements:
-
Control+o
thenv
to split horizontally -
Control+o
thenb
to split vertically -
Control+o
then;
to switch between current and last pane -
Control+o
thenh
,j
,k
,l
to move left, down, up, right respectively as vim does -
Control+o
thenz
to maximum/restore current pane -
Control+o
thenx
to close current pane
Copy&Paste:
We use xclip
be default, so you should install it through:
sudo apt-get install xclip
-
Control+o
then[
to enter copy mode - Press
v
to select blocks, orV
to select multiple lines, and theny
to copy it to clipboard - Goto where you want to paste, and press
i
to enter edit mode. PressControl+o
then]
to paste.
Comments