Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

tmux

tmux is a so called terminal multiplexer. A what? It allows you to have multiple terminal sessions inside of one terminal session. It also allows you to connect and disconnect from these sessions and organize them in multiple ways (panes, window).

Usage

Simply invoke tmux to start a new tmux session. You will notice a new (customizable) status bar at the bottom of your terminal. To control tmux you need to enter a prefix (default Ctrl+b). The following prefixes are interpreted as commands to tmux.

key command
? help
[ activate scroll mode, you need this to navigate through longer output, leave with ESC
d detaches from current session and gets you back to plain terminal
$ renames current session
c creates a new window
& kills the current window (confirm with y)
n switch to next window
p switch to previous window
% splits the current pane in two vertical panes
" splits the current pane into two horizontal panes
cursor keys switches between panes
! break out current pane to new window
: enter tmux command

Walkthrough: detaching and attaching

tmux
Ctrl+b, $, mysession
echo "I am in tmux"
Ctrl+b, d
echo "I am a plain terminal"
tmux ls
tmux a -t mysession

Enter tmux commands

tmux has a command interface as well. You can enter it by pressing prefix followed by :. You will see a input line at the bottom of your tmux session.

Walkthrough: synchronize the input to multiple panes

tmux
# split pane vertically
Ctrl+b, %
# syncronize-panes
Ctrl+b, :
setw synchronize-panes
echo hello
# de-syncronize-panes
Ctrl+b, :
setw synchronize-panes

Hint If you keep Ctrl pressed you can issue Ctrl-b,s to switch synchronisation state as well.