Tmux and how to design our own

2 minute read

Published:

Introduction

Many people are using the mouse as a tool to switch consoles of tasks, windows, … in monitoring, programming, and remote servers via SSH.

In the book tmux 2 - Productive Mouse-Free Development, the author mentioned that using tmux manage multiple terminal sessions in a single window using only your keyboard such as:

  • Manage and run programs side by side in panes
  • Mange a text editor, a database console, and a local web server within a single eviroment.
  • Quickly move between these windows and panes using only the keyboard.

As an AI Engineer, I will use it in mornitoring model training, depolyment, run programs. In this blog, I would like to introduce some of the basic concepts, how to design your tmux using tmux plugin.

What is Tmux?

Tmux is a terminal multiplexer, it enables number of terminals(or windows), each running a seperate program, to be created, accesed, and controlled from single screen.

The key elements to understanding when using tmux effectively.

  • Session - the entity that holds one or more windows like Workspace.
  • Window - the entity that holds panes in a session. Windows have layouts and can be split into panes.
  • Panes - is a pseudoterminal

Installation

$ sudo apt update
$ sudo apt install tmux

Tmux Command Lines

Create session

tmux new-session
tmux new -s <session_name>

Detach and attach session

Detach session

Crl + b + d

View list of sessions

tmux ls
tmux list-session

Attach session

# Current session
tmux a
# With specific session
tmux a -t <session_name>

Rename session

tmux rename-session -t <session_name> <new_session_name>

Kill session

# Kill specific session
tmux kill-session -t <session_name>
# Kill all session
tmux kill-server

Create, close and select Windows

Create a new window

Ctrl + b + c

Close current window

Ctrl + b + & (shift + 7)

Select windows

# Select with window id
Ctrl + b + <window_id>
# Select with previous and next window
Ctrl + b + n
Ctrl + b + p

Create, close and select panes

Create a new window

# Create right pane
Ctrl + b + %(shift + 5)
# Create bottm pane
Ctrl + b + "(shift + ')

Close current window

Ctrl + b + x --> press y

Select windows

# Select with direction
Ctrl + b + top/down/right/left
# Select with cycle
Ctrl + b + o

Scroll

With keyboard

Ctrl + b + [

With mouse

# Turn on
tmux set -g mouse on
# Turn off
tmux set -g mouse off

Design your tmux

Please visit here: Custom tmux

Reference