Tmux is an acronym for Terminal MUltipleXer. This acts as a window manager for your terminal. In other words, it can be used to create multiple sessions within a single terminal window. This is so vital since you can have several applications or commands executed side by side without requiring you to run a separate terminal.
The features provided by Tmux are:
- Window Splitting: it allows users to split the terminal onto multiple panels either horizontally or vertically. This makes it easier to view and work on multiple terminal sessions at once.
- Session Sharing: You can also collaborate on a single session by sharing the terminal window.
- Customization: It is so extensive and can be customized to suit your preferences. There are many customizations such as keybindings, status bar, change colours etc.
- Session Persistence: It retains the current state of the terminal sessions even when closed and reopened. This can be vital for the easy resumption of tasks.
- Detachable and Attachable: The sessions can be detached and later reattached to the terminal session. This makes it easier to switch between different terminal sessions.
- Scriptable and Automatable: It can be controlled and automated using scripts and other external tools.
- Remote Access: it allows you to connect to a Tmxu session on a remote machine. You can manage and control the terminal sessions remotely.
Join me in this guide as we learn the proper way to customize Tmux on Linux and macOS.
Install Tmux on your System
Before we customize it, we need to ensure that Tmux has been installed on the Linux or macOS system. This can be done using the commands below:
##On Ubuntu and Debian
sudo apt update
sudo apt install tmux
##On CentOS and Fedora
sudo yum install tmux
##On Rhel 8
sudo yum install http://galaxy4.net/repo/galaxy4-release-8-current.noarch.rpm
sudo yum install tmux
##On OpenSUSE
zypper install tmux
##on Arch Linux
pacman -S tmux
##On MacOS
brew install tmux
2. Customize Tmux on Linux and macOS
Once installed, Tmux can then be customized to suit your preference. There are so many things we can customize here. By default, Tmux stores its configuration file in ~/.tmux.conf directory. If you have an existing config, take a backup before we proceed with this customization.
Ensure that git is installed before we proceed to clone the sample config below:
cd
git clone https://github.com/gpakosz/.tmux.git
Once clones, create a symbolic link to ~/.tmux.conf:
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .
In the config, there are several configs defined. This includes:
- SSH/Mosh aware username and hostname status line information
- mouse mode toggle with
<prefix> m - uptime status line information
- visual theme inspired by Powerline
- optional highlight of the focused pane
- laptop battery status line information
- SSH/Mosh aware split pane (reconnects to remote server)
- support for 4-digit hexadecimal Unicode characters
- copy to OS clipboard (needs
reattach-to-user-namespaceon macOS,xsel,xclip, orwl-copyon Linux) - configurable new windows and panes behaviour (optionally retain current path)
Key bindings
There are also several keybindings in the config. The defined prefix combo for Tmux Keybinding is:
- Default prefix
C-b. - Secondary prefix
C-a
The <prefix> means you have to either hit Ctrl + a or Ctrl + b. For example, if you have the keybinding as <prefix> c means you have to hit Ctrl + a or Ctrl + b followed by c.
The keybindings in the config are:
<prefix> eopens the.localcustomization file copy with the editor defined by the$EDITORenvironment variable (defaults tovimwhen empty)<prefix> rreloads the configuration<prefix> Tabbrings you to the last active window<prefix> <and<prefix> >let you swap panesC-lclears both the screen and the Tmux history<prefix> C-ccreates a new session<prefix> blists the paste-buffers<prefix> -splits the current pane vertically<prefix> _splits the current pane horizontally<prefix> C-hand<prefix> C-llet you navigate windows (default<prefix> nand<prefix> pare unbound)<prefix> +maximizes the current pane to a new window<prefix> h,<prefix> j,<prefix> kand<prefix> llet you navigate panes ala Vim<prefix> H,<prefix> J,<prefix> K,<prefix> Llet you resize panes<prefix> Flaunches Facebook PathPicker (if available)<prefix> mtoggles mouse mode on or off<prefix> Enterenters copy-mode<prefix> ppastes from the top paste-buffer<prefix> Plets you choose the paste buffer to paste from<prefix> Ulaunches Urlview (if available)<prefix> C-flets you switch to another session by name
In case of any alterations to this sample config, you should refer to the sample .local customization file. In the below image, I have used <prefix> - to split the current pane vertically and <prefix> _ to split the current pane horizontally

Enabling the Powerline look
The Powerline was developed as a status-line plugin for Vim. This is a nifty look based on several symbols for your shell. There are several options that can be used to implement the symbols. These include:
- using a font that already has the powerline symbols. For example, the case of the 2.030R-ro/1.050R-it version of the Source Code Pro font
- Using a pre-patched font
- Using a prefered font alongside the Powerline font (that only contains the Powerline symbols): this highly depends on your operating system and your terminal emulator,
You can also modify the .local file by pressing <prefix> e and making the below adjustments. Esure that vim has been installed before you proceed.
tmux_conf_theme_left_separator_main='\uE0B0'
tmux_conf_theme_left_separator_sub='\uE0B1'
tmux_conf_theme_right_separator_main='\uE0B2'
tmux_conf_theme_right_separator_sub='\uE0B3'
Configure the Status Line
To configure the status line, you can modify your .local customization file. To modify it, use <prefix> e and modify the below variables as desired:
#{battery_bar}: horizontal battery charge bar#{battery_percentage}: battery percentage#{battery_status}: is battery charging or discharging?#{battery_vbar}: vertical battery charge bar#{circled_session_name}: circled session number, up to 20#{hostname}: SSH/Mosh aware hostname information#{hostname_ssh}: SSH/Mosh aware hostname information, blank when not connected to a remote server through SSH/Mosh#{loadavg}: load average#{pairing}: is session attached to more than one client?#{prefix}: is prefix being depressed?#{root}: is current user root?#{synchronized}: are the panes synchronized?#{uptime_y}: uptime years#{uptime_d}: uptime days, modulo 365 when#{uptime_y}is used#{uptime_h}: uptime hours#{uptime_m}: uptime minutes#{uptime_s}: uptime seconds#{username}: SSH/Mosh aware username information#{username_ssh}: SSH aware username information, blank when not connected to a remote server through SSH/Mosh
Enable Auto Start
After the adjustments have been made, you can set Tmux to run automatically when a terminal is lauched. To achieve that, modify your bashrc as shown.
cat <<EOF >> ~/.bashrc
[ -z "$TMUX" ] && { tmux attach || exec tmux new-session && exit;}
EOF
Source the profile:
source ~/.bashrc
Now you will have Tmux start when a terminal is lauched. For example through SSH:

There are many other customizations you can make, to do so, just modify the .local file using <prefix> e.
Verdict
This guide has provided the easiest and proper way to customize Tmux on Linux and macOS. Now you can have an appealing terminal. Fee free to share your experience in the comments below.
Recommended Linux Books to read:
- Best Linux Books for Beginners & Experts
- Best Linux Bash Scripting Books
- Top RHCSA / RHCE Certification Study Books
- Best Top Rated CompTIA A+ Certification Books
- Best LPIC-1 and LPIC-2 certification study books
See more: