If tmux
is not installed, then install it or buid from sources.
- MacOS:
brew install tmux
- CentOS family:
yum install tmux
- Ubuntu family:
apt-get install tmux
# Start new
tmux
# Start new using iTerm2 as terminal device (on MacOS)
tmux -CC
# Reattach to existing session - any of the following commands
tmux a
tmux at
tmux attach
# Start new with session name
tmux new -s myname
# Attach to named:
tmux a -t myname
List sessions:
tmux ls
tmux kill-session -t myname
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
Within terminal session tmux
is controlled by keyboard commands.
To invoke any command - hit command prefix (default ctrl+b
) followed by command.
E.g. to et help press ctrl-b
and then ?
. You'll get list of all tmux
commmands and key bindings
:new<CR> new session
s list sessions
$ name session
d detach client (exit from tmux)
To execute command press prefix followed by corresponding key. Default command prefix ctrl+b
c create window
w list windows
n next window
p previous window
f find window
, name window
& kill window
% vertical split
" horizontal split
o Swap panes
q Show pane numbers
x Kill pane
z Maximize pane to whole windows / restore pane size
space Toggle between layouts
q Show pane numbers, when the numbers show up type the key to goto that pane)
{ Move the current pane left
} Move the current pane right
z toggle pane zoom
How to resize panes of current screen layout
:resize-pane -D Resizes the current pane down
:resize-pane -U Resizes the current pane upward
:resize-pane -L Resizes the current pane left
:resize-pane -R Resizes the current pane right
:resize-pane -D 20 Resizes the current pane down by 20 cells
:resize-pane -U 20 Resizes the current pane upward by 20 cells
:resize-pane -L 20 Resizes the current pane left by 20 cells
:resize-pane -R 20 Resizes the current pane right by 20 cells
:resize-pane -t 2 20 Resizes the pane with the id of 2 down by 20 cells
:resize-pane -t -L 20 Resizes the pane with the id of 2 left by 20 cells
t big clock
? list shortcuts
: prompt
# Mouse support - set to on if you want to use the mouse
* setw -g mode-mouse off
* set -g mouse-select-pane off
* set -g mouse-resize-pane off
* set -g mouse-select-window off
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# Center the window list
set -g status-justify centre
# Maximize and restore a pane
unbind Up bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
unbind Down
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
Why it is needed? Because some distros (e.g. CentOS) comes with old tmux which lacks cool features, such as integration with Mac iTerm2 etc. Check your tmux version: tmux -V
. If the version you get is less then 2.2
, then do yourself a favor and build a latest version from the sources.
- Get and build
libevent
library (tmux depends on it)
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar xzf libevent-2.1.8-stable.tar.gz && cd libevent-2.1.8-stable
./configure && make
sudo make install
> /usr/local/lib
> libtool: finish: PATH="/sbin:/bin:/usr/sbin:/usr/bin:/sbin" ldconfig -n /usr/local/lib
> ----------------------------------------------------------------------
> Libraries have been installed in:
> /usr/local/lib
# Make library linkable
ldconfig -n /usr/local/lib
- Get and build
tmux
. 2.8 is latest build in Jan 2019, check if there is newer one now
wget https://github.com/tmux/tmux/releases/download/2.8/tmux-2.8.tar.gz
tar xzf tmux-2.8.tar.gz && cd tmux-2.8
./configure && make
sudo make install