If you’ve been using Linux for some time, chances are that you’ve used (or are still using) a terminal multiplexer of some sorts. Usually it’s GNU Screen, which I’ve been using myself for quite some time. However I recently discovered Tmux, which I want to talk about.

Terminal multiplexer, what’s that?

Terminal multiplexers allow you to create, navigate through and use multiple virtual terminals in one window. You can navigate through panes and windows with keyboard shortcuts, which usually are faster to use than to spin up another terminal window.

Another great thing multiplexers like Tmux do is window tiling. Split your window into multiple panes for easier server monitoring and watch each tool as it’s being updated simultaneously, change to another virtual window and you’re back to coding or doing whatever you want. It speeds up your work and increases your productivity rate. Personally, I’ve started using GNU Screen just a few months ago and discovered Tmux only a week or so ago, but I’m much happier and more productive with them than ever before.

Why Tmux?

  • It is simple

  • It has great documentation

  • Supports horizontal and vertical splitting (panes) with automatic (or manual) height/width adjustment

  • You can easily customize it

  • Even out of the box it is nicely configured

As you can see in the image I have opened up my code in one pane and python interpreter below it. It’s not as impressive as it could be. A step up would be running editor, documentation, tests and shell in 4 panes and it’s not even breaking a sweat.

Configuring Tmux

set -g prefix C-a
unbind %
bind \ split-window -h
bind - split-window -v
bind-key k select-pane -U
bind-key j select-pane -D
bind-key h select-pane -L
bind-key l select-pane -R

unbind C-b
bind C-a send-prefix
#force reload of a config file
unbind r
bind r source-file ~/.tmux.conf

#quick pane cycling
unbind ^A
bind ^A select-pane -t :.+

This is the configuration file ~/.tmux.conf that I currently use. Firstly it remaps prefix hotkey to C-a (Ctrl + a) and maps hotkeys for vim-like behavior navigating around panes.

So C-a j would move you one pane down, C-a l would move you one pane to the right and so on.

A few commands I found useful:

Ctrl-b : resize-pane -D 20 (Resizes the current pane down by 20 cells) Ctrl-b : resize-pane -U 20 (Resizes the current pane upward by 20 cells) Ctrl-b : resize-pane -L 20 (Resizes the current pane left by 20 cells) Ctrl-b : resize-pane -R 20 (Resizes the current pane right by 20 cells)