Sunday, June 26, 2011

tmux (a terminal multiplexer similar to screen)

This is a list of the most useful keys/commands (IMHO) for tmux, a terminal multiplexer like the old screen.

Global config file: /etc/tmux.conf
Per-user config file: ~/.tmux.conf

Configuration options:

set-option -g prefix Ctrl-a # this will bind the Ctrl-a combination to the prefix key
set-option -g prefix ` # this will bind the ` key to the prefix key
setw -g monitor-activity on # mark visually the window that had activity on the status bar
set -g visual-activity on # pop a message in the status bar for the window that had activity

The default prefix, or the key that precedes the command is Ctrl-b

prefix c Create new window
prefix d Detach current client
prefix l Move to previously selected window
prefix n Move to the next window
prefix p Move to the previous window
prefix & Kill the current window
prefix , Rename the current window
prefix % Split the current window into two vertical panes
prefix q Show pane numbers (quickly press the number shown and you'll go to that pane)
prefix o Switch to the next pane
prefix ? List all keybindings

Window management:

prefix n Go to the next window
prefix p Go to the previous window
prefix l Go to the previous selected window
prefix w (List all windows / window numbers)
prefix window_number Go to the specified window number
prefix f Type the window name and tmux will try to find and switch to it
prefix { Move current pane to the left
prefix } Move current pane to the right
prefix space Rearrange windows (even-horizontal, even-vertical, main-horizontal, main-vertical and tiled)
prefix arrow_keys You can use the prefix key plus the up/right/down/left arrows to switch panes
prefix [ Enters copy mode so you can scroll up/down through that pane's terminal history (with Shift + PgUp/PgDown)

Command mode:

You can go into command mode by typing

prefix :

Inside command mode you can type whatever command tmux supports. One important tip here is that the command mode has a history function, so while inside you can use the up and down arrows to go through the history of commands you entered

A couple interesting commands are

rename-window name Rename current window
rename-session name Rename current session
break-pane Make the current pane into its own window
switch -t session_name Switch to the session named session_name
ls List sessions

After you have your client detached:

tmux new -s session_name Create a new session named session_name
tmux attach -t session_name Attach the client to the session named session_name (tip: you can type only a couple chars of the session name, tmux is intelligent enough to find out)
tmux ls This is the same as tmux list-sessions

I'm using squeeze which currently has the 1.3-2+squeeze1 version that has a little problem to properly draw the pane divisions on PuTTY so I installed a greater version from the squeeze-backports which is 1.4-6~bpo60+1 that correct this issue.

Extracted from the tmux changelog:

CHANGES FROM 1.3 TO 1.4, 27 December 2010

* Use UTF-8 line drawing characters on UTF-8 terminals, thus fixing some terminals (eg putty) which disable the vt100 ACS mode switching sequences in UTF-8 mode. On terminals without ACS, use ASCII equivalents.

No comments:

Followers

About me

Santa Fe, Argentina
Programador Web, PHP, MySQL, JQuery, Administrador Linux. LAMP, Lighttpd, Nginx.