Featured image of post Tmux

Tmux

How to use Tmux to split panes in the CLI.

TMUX

Split your terminal screen up!

Here is my brief get up and go guide to Tmux. Tmux is a great tool to use when you need multiple panes in the terminal and especially useful if you don’t have access to a GUI. You can also create sessions with Tmux to enter and exit different workspaces. It can be installed in the usual fashion (apt, pacman, dnf, snap even) on all Linux distros as it is widely used.

Here is how Tmux appears:

Tmux hard at work

Currently, I prefer to use Terminator on my distro of choice so I don’t use Tmux as much as I used to but nonetheless I still find myself using it regularly. Below are some of the commands you can use to create and use separate panes. Preceding most commands is Ctrl+B. This is sometimes referred to as the prefix. It will initiate a mode that is followed by key inputs that can amend the current view:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Ctrl+B Shift+% - split pane vertically

Ctrl+B Shift+" - split pane horizontally

Ctrl+B then arrow to change pane

Ctrl+B c - New window (number at bottom. Starts at 0)

Ctrl+B 0 - Go to window 0

Ctrl+B 1 - Go to window 1

Ctrl+B z - Zoom window to fullscreen and back again


Type "exit" or Ctrl + D to close the current pane


Sessions:

Ctrl+B d - Detach or leave session

tmux ls - Summary of windows open in background

tmux attach -t 0 - Attach to session (State is preserved)

tmux rename-session -t 0 git - Rename the session 'git'

tmux kill-session -t git - Ends git session


One of the most useful commands is this:

Ctrl+B : set synchronize-panes on - Sync all panes 

This way you can enter text into all panes at once. Super handy!

There is much more to Tmux. You can edit the config file in your home directory and use plugins. It is extremely versatile. I might follow this up soon. Some of my config dotfiles are available in my GitLab repo if you are interested in some examples of how I set up my terminal.

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy