Tmux
From FrugalWiki
Contents |
Intro
Tmux stands for 'terminal multiplexer', it is a program similar to dtach or GNU screen. It is used to run multiple commands in windows in the same terminal. The whole session can be detached and then reattached. It can provide continuous operation even when the network connection is lost.
As opposed to GNU screen, tmux offers easier configuration and clear documentation, a more liberal BSD license and continuous, live development (as of 2009). Tmux is now part of the base OpenBSD and FreeBSD system.
The program operates in a server-client relationship, the sessions use sockets (by default under /tmp/tmux-*/) for communication. A session allows multiple user connections in a controllable manner.
From the outermost layer, the following components make up tmux:
- server
- session
- window - the part actually running some program
- pane - a divided part of the window - optional
- client - the program running in the window, typically, a shell and its children
The author of tmux is Nicholas Marriott (NicM), OpenBSD developer.
Installation
ncurses is required. Frugalware -current imported tmux in November 2009.
Syntax
tmux [options...] [[command] [command-options...]]
There are some commands which can be called from any shell (tmux ls, for example), some can only be used from the built-in command line mode.
Most of them have a short alias, and you can abbreviate any command to its shortest unique form, for example, 'att' can be used instead of 'attach'.
Examples:
Connect to the default session, detaching any other user (roughly equivalent with 'screen -DR'):
tmux attach -d
OR
tmux att -d
List active sessions:
tmux list-sessions
OR
tmux list-se
OR
tmux ls
Command line options (sample)
Option | Comment | Default value |
-f $file | config file to use | ~/.tmux.conf |
-L $socketname | socket file to use | /tmp/tmux-*/default) |
-S $socketdir | socket directory to use | /tmp/tmux-*/ |
-v ... -vvvv | debug in different depths | (logs will appear in $PWD) |
Commands (sample)
Option | Alias | Function |
attach-session | attach, att | attach to a session |
kill-server | N/A | terminate server and every window |
kill-session | N/A | terminate a session |
list-clients | lsc | list clients |
list-sessions | ls | list sessions |
list-windows | lsw | list windows |
new-session | new | start new session |
start-server | start | start only the 'empty' server |
Key bindings
The default bindkey is Ctrl-b. For example, detach is 'Ctrl-b d'.
Add this to ~/.tmux.conf to use the screen style Ctrl-a:
set -g prefix C-a bind-key C-a last-window
The most important are similar to GNU screen's key bindings:
c | create | create new window |
d | detach | detach from session |
n | next-window | next window |
p | previous-window | previous window |
q | display-panes | show numbers in each pane |
x | kill-pane | kill pane with confirmation |
& | kill-window | kill window with confirmation |
, | rename-window | rename window |
Space | next-layout | toggle pane layouts |
Arrows | *-pane | moving between panes (up, down...) |
[ ] | copy-mode, paste-buffer | copy, paste |
0 1... 9 | select-window | select window 'n' |
: | command-prompt | tmux command interface |
= | scroll-mode | scrollback mode (exit: Esc) |
? | list-keys | list all key bindings |
screen - tmux cross reference (draft)
Option | screen | tmux |
User config file | ~.screenrc | ~.tmux.conf |
Session files | /tmp/uscreens/ | /tmp/tmux-10/ |
List sessions | screen -ls | tmux ls |
Default bindkey | Ctrl-a | Ctrl-b |
Rename window | <bindkey> Shift-a | <bindkey> , |
Reattach | screen -x | tmux attach |
Reattach +detach others | screen -DR | tmux attach -d |
References
tmux website (Sourceforge) - changelog, FAQ, screenshot...
tmux manual (PDF)