Tutorial: tmux

I found a little gem that I am using if I have to do serveral things at the same time on the same server.
Like testing my scripts and looking at the logs and at the mongodb client at the same time.

The tool is tmux which is a terminal multiplexer.

It allows you to split a terminal into smaller peaces and to navigate between the peaces and whole panes.

Installation is simple:

apt-get install tmux

You can start the tool with "tmux".
After that you can split your screen with following commands
Split vertical:

Ctrl-b %

Split horizontal:

Ctrl-b "

Or both:

You can navigate between the different panes with:

Ctrl-b o

You can add a new page too:

Ctrl-b c

And switch between them with:

Ctrl-b n

You can change the title of one screen too by:

Ctrl-b ,

Like screen you can detach and attach to running sessions:
List sessions:

tmux list-sessions

Detach session:

Ctrl-b d

Attach session:

tmux attach -t [session name]

Best of all is the configuration of tmux itself:

nano ~/.tmux.conf


# Start numbering of windows at 1
set -g base-index 1

# Set up a status bar
set -g status-bg black
set -g status-fg white
set -g status-left "#[fg=green]"
set -g status-right "#[fg=green]#H"
#Or a shell command
#set -g status-right "#[fg=yellow]#(uptime)"

# Highlight active window
set-window-option -g window-status-current-bg red

# Set clipboard and history limit
set-option -g set-clipboard on
set -g history-limit 1000

# Set modifier from Ctrl+b to Ctrl+a, just like screen (fisle)
set-option -g prefix C-a 

# mouse support (dabtech)
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on