amuck-landowner

Running a terminal multiplexer

wlanboy

Content Contributer
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 %

screen1.jpg
Split horizontal:


Ctrl-b "

screen2.jpg
Or both:
screen3.jpg

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

screen4.jpg
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

Content:

Code:
# 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
 
Last edited by a moderator:

fisle

Active Member
My favourite config options:

Code:
set-option -g prefix C-a  # Set modifier from Ctrl+b to Ctrl+a, just like screen

unbind ^A 

bind ^A last-window  # Press Ctrl+A twice and it switches to previously active window
 

peterw

New Member
Tmux is nice but I use the lightweight dvtm.

New window: Ctrl-g + c

Close window: Ctrl-g + x

Next window: Ctrl-g + j

Previous window: Ctrl-g + k
 

dabtech

New Member
Mouse support can also be added, so panes can be selected via mouse clicks and resized by grabbing borders.

Code:
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
 

Shados

Professional Snake Miner
If you're using tmux now, you may also want to check out Byobu - it has some nice enhancements built on top of tmux/screen :).
 
Top
amuck-landowner