TMUX - A Terminal Multiplexer

1 minute read

You may want to see multiple terminals in a single screen. For instance, you want to edit the code while monitoring the system utilization or kernel log from serial communication. Tmux is a terminal multiplexer which allows to split your screen to multiple terminals. You can also make program keep running while not visible in the background.

tmux

How to install?

Ubuntu and debian

$ sudo apt install tmux

CentOS and Fedora

$ sudo yum install tmux

macOS

$ brew install tmux

Components

  • Session: basic unit of tmux consists of multiple windows
  • Window: single terminal screen
  • Pane: divided screen from a single window.

When you launch tmux, you may create a new session and generates multiple windows in it. Each window can be divided into multiple panes.

Commands

tmux: start new window

tmux ls : list all available sessions

tmux attach: attach the session

tmux detatch: detach the session

Shortcuts

CTRL + b : prefix key by default.

[prefix] + : command mode where you can type tmux commands

[prefix] + c : creates a new window

[prefix] + 0-9 : switch to a window with its index

[prefix] + " : split the active pane horizontally

[prefix] + % : split the active pane vertically

[prefix] + arrow key : switch to another pane

keep [prefix] pressed + arrow key : resize the active pane

[prefix] + z : zoom out the active pane

[prefix] + x : kill the current window

[prefix] + d : detach the session

Configuration

Like ~/.bashrc, you can set local configuration to ~/tmux.conf. The global configuration file should be located at /etc/tmux.conf.

You can make your own configuration.

FYI - A good example