PRIMARY CATEGORY → SERVER SETUP

TMUX → Terminal Multiplexer

It allows to create and access multiple Terminal Sessions through a Server

Tmux works with Sessions

A Session can contain one or several Windows

Each Window can be divided into several Panes

More information here

Man Page


Installation

Dependencies

Tmux requires some dependencies to be compiled such as a C compiler, libraries…

Install all of them as follows →

sudo apt install -y -- libevent-dev ncurses-dev build-essential bison pkg-config

If any of the above tools are not available as packages, build them from source

See here

Tmux

Reference

Download the source code from the Releases Page and Install it as follows →

wget https://github.com/tmux/tmux/releases/download/X.Xa/tmux-X.Xa.tar.gz
tar -zxf tmux-*.tar.gz
cd tmux-*/
./configure
make && sudo make install
cd - && rm -rf -- ./tmux-*

That’s it!

$ command -V tmux
tmux is /usr/local/bin/tmux

The default installation directory is /usr/local. To change it, add the --prefix option to the ./configure script

./configure --prefix=/usr/bin
Uninstallation

According to the Makefile, during installation via the sudo make install command, the installed files are →

  • /usr/local/bin/tmux
  • /usr/local/share/man/man1/tmux.1

To remove them, proceed as follows →

sudo rm -rf -- /usr/local/bin/tmux /usr/local/share/man/man1/tmux.1

Configuration File

Tmux.conf

See here

Default Prefix Modification
~/.tmux.conf
unbind-key C-b
set-option -g prefix M-i
bind-key M-i send-prefix

Shortcuts

Default Prefix → C-b

Custom Prefix → M-i

Shorcuts’ Meaning
KeyMeaning
<leader>M-i<leader> + a → Alt+i+a
CControlC-c → Control+c
MAltM-a → Alt+a
SShiftS-o → Shift+o
SuperWindowsSuper-s → Windows+s
ReturnEnterC-S-Return → Control+Shift+Enter
-+C-z → Control+z
{a,b,c,d}a b c dC-{a,b,c,d} → C-a C-b C-c C-d
Sessions
Commands
ActionShorcut
Create Sessiontmux new -s TMUX_SESSION_NAME_OR_ID
Kill Sessiontmux kill-sess -t TMUX_SESSION_NAME_OR_ID
List Sessionstmux ls → Name
tmux ls -F '#{session_id}: #{session_name}' → ID/Name
Kill Server (Kill All Sessions)tmux kill-server
Session Attachtmux a -t TMUX_SESSION_NAME_OR_ID
Last Session Attachtmux a
Shortcuts
ActionShorcut
Session Detach<leader> + d
Session Rename<leader> + $
Toogle to Sessions Select Mode<leader> + s
Session Movement⬅️➡️<leader> + ( <leader> + )
Windows
ActionShortcut
Windows Creation<leader> + c
Windows Closing<leader> + &
Windows Rename<leader> + comma
Windows Focus⬅️➡️<leader> + p <leader> + n
Windows Focus (Numeric)<leader> + {0..9}
Windows Movement⬅️➡️<leader> + S-comma <leader> + S-dot
Toogle to Windows Select Mode<leader> + w
Panes
ActionShortcut
Vertical Split<leader> + Return
Horizontal Split<leader> + dash
Pane Closing<leader> + x
Close All Panes (Except the focused one)<leader> + C-o
Pane Zoom In/Out<leader> + z
Pane Movement⬆️⬇️⬅️➡️<leader> + S-{k,j,h,l}
Pane Focus⬆️⬇️⬅️➡️<leader> + C-{k,j,h,l}
Pane Resize⬆️⬇️⬅️➡️<leader> + M-{k,j,h,l}
Pane Resize - Reset (Toogle to Tiled Layout)<leader> + r
Toogle between All Layouts<leader> + Space
Pane Detach into a New Window<leader> + !
Misc
ActionShortcut
TMUX Cheatsheet (Keybindings)<leader> + ?
Toogle to Command Mode<leader> +