Tmux: The Terminal Multiplexer Replacing Screen
Introduction
Tmux has many advantages over screen and serves as a terminal multiplexer. This functionality is extremely practical and even essential once you’ve started using it.
Installation
|
|
Usage
To use tmux, simply launch it:
|
|
Like screen, tmux uses a key combination to access its internal functions. By default, it’s “Ctrl+b” (which can be modified) that is used. To start, you can easily get help (don’t forget to press “Ctrl+b” before pressing any key):
Description | Keys |
---|---|
Get help | ? |
Window Management
You can manage your windows as follows (don’t forget to press “Ctrl+b” before pressing any key):
Description | Keys |
---|---|
Create a new window | c |
Get a list of open windows | w |
Move to the next window | n |
Move to the previous window | p |
Move to the last used window | l |
Move to a window by its number | 0 1 2 3 4 5 6 7 8 9 |
Search in window buffers | f then “window search name” |
Rename the current window | , |
Force close a window | & |
Display time | t |
Split
You can split the screen in several ways:
Description | Keys |
---|---|
Horizontally split the screen | " |
Vertically split the screen | % |
Move to the previous pane | { |
Move to the next pane | } or o |
Move to the pane corresponding to the key | ← → ↑ ↓ |
Get pane numbers | q |
Change visual organization of panes | [space] |
Resize a pane | Alt+(← → ↑ ↓) |
Convert a pane from a split into a window | ! |
Convert a window for integration into a split _ -h: horizontally _ -s 0.0: window 0 and pane 0 * -p 75: taking 75% of window | :joinp -h -s 0.0 -p 75 |
History
By default, Tmux keeps only 2000 lines of history. Here’s how to navigate:
Description | Keys |
---|---|
Scroll up through history | ↑↑ (PageUP) |
Scroll down through history after scrolling up | ↓↓ (PageDOWN) |
Select lines from history (after PageUP) | [space] then (↑/↓) |
Copy selection | [enter] |
Paste selection | = |
Sessions
Session management is something very practical. It’s always useful to be able to exit an SSH session and leave time-consuming tasks running, or to protect against network disconnections. That’s why when you’re in tmux, it’s possible to detach from your tmux:
Description | Keys |
---|---|
Detach from tmux session | d |
List tmux sessions | s |
Switch to next tmux session | ) |
Switch to previous tmux session | ( |
Then reattach later:
|
|
This command also allows multiple participants to see exactly the same thing.
Cheat Sheet
I’ve created a cheat sheet for those interested:
Customization
You can customize all kinds of things (I’ll let you read the man page as it’s so complete), and here’s my configuration:
|
|
Launch a Program with Tmux at Boot
You may want to launch weechat (IRC client) or other program in tmux when your machine starts. To do this, it’s easy:
|
|
Here we’re asking tmux to create a new session via the deimos user.
Resources
- http://tmux.sourceforge.net/
- http://myhumblecorner.wordpress.com/2011/08/30/screen-to-tmux-a-humble-quick-start-guide/
- http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/
- http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
- http://www.dayid.org/os/notes/tm.html
- http://tmux.svn.sourceforge.net/viewvc/tmux/trunk/examples/
- http://linux-attitude.fr/post/configuration-de-tmux?utm_source=rss&utm_medium=rss&utm_campaign=configuration-de-tmux
Last updated 25 Jan 2013, 07:47 +0200.