What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
Download tmux 1.8 or get the development version. tmux is hosted on SourceForge and needs libevent and ncurses .
Tmux is a terminal multiplexer: it enables a number of terminals to be
created, accessed, and controlled from a single screen. tmux may be
detached from a screen and continue running in the background, then later
reattached.
When tmux is started it creates a new session with a single window and
displays it on screen. A status line at the bottom of the screen shows
information on the current session and is used to enter interactive
commands.
A session is a single collection of pseudo terminals under the management
of tmux. Each session has one or more windows linked to it. A window
occupies the entire screen and may be split into rectangular panes, each
of which is a separate pseudo terminal (the pty(4) manual page documents
the technical details of pseudo terminals). Any number of tmux instances
may connect to the same session, and any number of windows may be present
in the same session. Once all sessions are killed, tmux exits.
Each session is persistent and will survive accidental disconnection
(such as ssh(1) connection timeout) or intentional detaching (with the
`C-b d' key strokes). tmux may be reattached using:
$ tmux attach
In tmux, a session is displayed on screen by a client and all sessions
are managed by a single server. The server and each client are separate
processes which communicate through a socket in /tmp.
The options are as follows:
-2 Force tmux to assume the terminal supports 256 colours.
-C Start in control mode (see the CONTROL MODE section).
Given twice (-CC) disables echo.
-c shell-command
Execute shell-command using the default shell. If
necessary, the tmux server will be started to retrieve the
default-shell option. This option is for compatibility
with sh(1) when tmux is used as a login shell.
-f file Specify an alternative configuration file. By default,
tmux loads the system configuration file from
/etc/tmux.conf, if present, then looks for a user
configuration file at ~/.tmux.conf.
The configuration file is a set of tmux commands which are
executed in sequence when the server is first started.
tmux loads configuration files once when the server process
has started. The source-file command may be used to load a
file later.
tmux shows any error messages from commands in
configuration files in the first session created, and
continues to process the rest of the configuration file.
-L socket-name
tmux stores the server socket in a directory under
TMUX_TMPDIR, TMPDIR if it is unset, or /tmp if both are
unset. The default socket is named default. This option
allows a different socket name to be specified, allowing
several independent tmux servers to be run. Unlike -S a
full path is not necessary: the sockets are all created in
the same directory.
If the socket is accidentally removed, the SIGUSR1 signal
may be sent to the tmux server process to recreate it.
-l Behave as a login shell. This flag currently has no effect
and is for compatibility with other shells when using tmux
as a login shell.
-q Set the quiet server option to prevent the server sending
various informational messages.
-S socket-path
Specify a full alternative path to the server socket. If
-S is specified, the default socket directory is not used
and any -L flag is ignored.
-u tmux attempts to guess if the terminal is likely to support
UTF-8 by checking the first of the LC_ALL, LC_CTYPE and
LANG environment variables to be set for the string
"UTF-8". This is not always correct: the -u flag
explicitly informs tmux that UTF-8 is supported.
If the server is started from a client passed -u or where
UTF-8 is detected, the utf8 and status-utf8 options are
enabled in the global window and session options
respectively.
-v Request verbose logging. This option may be specified
multiple times for increasing verbosity. Log messages will
be saved into tmux-client-PID.log and tmux-server-PID.log
files in the current directory, where PID is the PID of the
server or client process.
command [flags]
This specifies one of a set of commands used to control
tmux, as described in the following sections. If no
commands are specified, the new-session command is assumed.
KEY BINDINGS
tmux may be controlled from an attached client by using a key combination
of a prefix key, `C-b' (Ctrl-b) by default, followed by a command key.
The default command key bindings are:
C-b Send the prefix key (C-b) through to the application.
C-o Rotate the panes in the current window forwards.
C-z Suspend the tmux client.
! Break the current pane out of the window.
" Split the current pane into two, top and bottom.
# List all paste buffers.
$ Rename the current session.
% Split the current pane into two, left and right.
& Kill the current window.
' Prompt for a window index to select.
, Rename the current window.
- Delete the most recently copied buffer of text.
. Prompt for an index to move the current window.
0 to 9 Select windows 0 to 9.
: Enter the tmux command prompt.
; Move to the previously active pane.
= Choose which buffer to paste interactively from a list.
? List all key bindings.
D Choose a client to detach.
[ Enter copy mode to copy text or view the history.
] Paste the most recently copied buffer of text.
c Create a new window.
d Detach the current client.
f Prompt to search for text in open windows.
i Display some information about the current window.
l Move to the previously selected window.
n Change to the next window.
o Select the next pane in the current window.
p Change to the previous window.
q Briefly display pane indexes.
r Force redraw of the attached client.
s Select a new session for the attached client
interactively.
L Switch the attached client back to the last session.
t Show the time.
w Choose the current window interactively.
x Kill the current pane.
{ Swap the current pane with the previous pane.
} Swap the current pane with the next pane.
~ Show previous messages from tmux, if any.
Page Up Enter copy mode and scroll one page up.
Up, Down
Left, Right
Change to the pane above, below, to the left, or to the
right of the current pane.
M-1 to M-5 Arrange panes in one of the five preset layouts: even-
horizontal, even-vertical, main-horizontal, main-
vertical, or tiled.
M-n Move to the next window with a bell or activity marker.
M-o Rotate the panes in the current window backwards.
M-p Move to the previous window with a bell or activity
marker.
C-Up, C-Down
C-Left, C-Right
Resize the current pane in steps of one cell.
M-Up, M-Down
M-Left, M-Right
Resize the current pane in steps of five cells.
Key bindings may be changed with the bind-key and unbind-key commands.
Installation
Install tmux, available in the Official Repositories.
Configuration
A user-specific configuration file should be located at ~/.tmux.conf
, while a global configuration file should be located at /etc/tmux.conf
. Default configuration files can be found in /usr/share/tmux/
.
Key bindings
Prefix all commands with Ctrl-b
Cmd
Action
c
Create a new window
n
Change to next window
p
Change to previous window
"
Split pane horizontally
%
Split pane vertically
,
Rename current window
o
Move to next pane
By default, command key bindings are prefixed by Ctrl-b. For example, to vertically split a window type Ctrl-b %
.
After splitting a window into multiple panes, you can resize a pane by the hitting prefix key (i.e. Ctrl-b
) and, while continuing to hold Ctrl, press Left/Right/Up/Down. Swapping panes is achieved in the same manner, but by hitting o instead of a directional key.
If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:
0 commenti:
Post a Comment