Utilities
1.1 seq
1.2 tmux
1.3 tree
1.4 rsync
1.5 SFTP
1.2 tmux
On this page:
1.2.1 Synopsis
1.2.2 Description
1.2.3 Options
1.2.4 Generalities on commands
1.2.5 Session and clients
1.2.6 Windows
1.2.7 Panes
1.2.8 Tmux options
1.2.9 Mouse
1.2.10 Status line
1.2.11 Buffers
1.2.12 Hooks
1.2.13 Examples
1.2.14 Author
8.1

1.2 tmux

tmux – terminal multiplexer

1.2.1 Synopsis

tmux [-2CDluvV] [-c shell-command] [-f file] [-L socket-name]

     [-S socket-path] [-T features] [command [flags]]

1.2.2 Description

tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. It 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. 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.

The server and each client are separate processes which communicate through a socket in /tmp.

1.2.3 Options
1.2.4 Generalities on commands

Each command may be bound to a key with the bind-key command or run from the shell prompt, a shell script, a configuration file or the command prompt.

Each command is terminated by a newline or a semicolon (;). Commands separated by semicolons together form a command sequence – if a command in the sequence encounters an error, no subsequent commands are executed. It is recommended that a semicolon used as a command separator should be written as an individual token.

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. Some of the default shortcuts:

Key

 

Action

C-b

 

Send the prefix key (C-b) through to the application

C-z

 

Suspend the tmux client

?

 

List all key bindings

:

 

Enter the tmux command prompt

#

 

List all paste buffers

=

 

Choose which buffer to paste interactively from a list

[

 

Enter copy mode to copy text or view the history

]

 

Paste the most recently copied buffer of text

-

 

Delete the most recently copied buffer of text

f

 

Prompt to search for text in open windows

t

 

Show the time

w

 

Choose the current window interactively

0 to 9

 

Select windows 0 to 9

'

 

Prompt for a window index to select

&

 

Kill the current window

,

 

Rename the current window

1.2.5 Session and clients

The following are some of the commands to manage clients and sessions:
  • list-sessions [-F format] [-f filter]

    (alias: ls)

    List all sessions managed by the server.

  • has-session [-t target-session]

    (alias: has)

    Report an error and exit with 1 if the specified session does not exist. If it does exist, exit with 0.

  • new-session [-AdDEPX] [-c start-directory] [-e environment] [-f flags]

                [-F format] [-n window-name] [-s session-name] [-t group-name]

                [-x width] [-y height] [shell-command]

    (alias: new)

    Create a new session with name session-name. The new session is attached to the current terminal unless -d is given. window-name and shell-command are the name of and shell command to execute in the initial window. The -A flag makes new-session behave like attach-session if session-name already exists.

  • kill-session [-aC] [-t target-session]

    Destroy the given session, closing any windows linked to it and no other sessions, and detaching all clients attached to it. If -a is given, all sessions but the specified one is killed.

  • kill-server

    Kill the tmux server and clients and destroy all sessions.

  • rename-session [-t target-session] new-name

    (alias: rename)

    Rename the session to new-name.

  • attach-session [-dErx] [-c working-directory] [-f flags] [-t target-session]

    (alias: attach)

    If run from outside tmux, create a new client in the current terminal and attach it to target-session. If used from inside, switch the current client. The target-session rules for attach-session are slightly adjusted: if tmux needs to select the most recently used session, it will prefer the most recently used unattached session.

  • list-clients [-F format] [-t target-session]

    (alias: lsc)

    List all clients attached to the server. If target-session is specified, list only clients connected to that session.

  • detach-client [-aP] [-E shell-command] [-s target-session] [-t target-client]

    (alias: detach)

    Detach the current client if bound to a key, the client specified with -t, or all clients currently attached to the session specified by -s. The -a option kills all but the client given with -t. If -P is given, send SIGHUP to the parent process of the client, typically causing it to exit. With -E, run shell-command to replace the client.

1.2.6 Windows

Some of the commands pertaining windows:
  • list-windows [-a] [-F format] [-f filter] [-t target-session]

    (alias: lsw)

    If -a is given, list all windows on the server. Otherwise, list windows in the current session or in target-session.

  • new-window [-abdkPS] [-c start-directory] [-e environment] [-F format]

               [-n window-name] [-t target-window] [shell-command]

    (alias: neww)

    Create a new window.

  • kill-window [-a] [-t target-window]

    (alias: killw)

    Kill the current window or the window at target-window, removing it from any sessions to which it is linked. The -a option kills all but the window given with -t.

  • rename-window [-t target-window] new-name

    (alias: renamew)

    Rename the current window, or the window at target-window if specified, to new-name.

  • last-window [-t target-session]

    (alias: last)

    Select the last (previously selected) window. If no target-session is specified, select the last window of the current session.

  • select-window [-lnpT] [-t target-window]

    (alias: selectw)

    Select the window at target-window.

1.2.7 Panes

Each window displayed by tmux may be split into one or more panes; each pane takes up a certain area of the display and is a separate terminal.

By default, a tmux pane permits direct access to the terminal contained in the pane. A pane may also be put into one of several modes:
  • Copy mode: permits a section of a window or its history to be copied to a paste buffer for later insertion into another window. This mode is entered with the copy-mode command, bound to [ by default. Copied text can be pasted with the paste-buffer command, bound to ].

  • View mode: like copy mode but is entered when a command that produces output, such as list-keys, is executed from a key binding.

  • Choose mode: allows an item to be chosen from a list. This may be a client, a session or window or pane, or a buffer. This mode is entered with the choose-buffer, choose-client and choose-tree commands.

To be expanded.

1.2.8 Tmux options

The appearance and behaviour of tmux may be modified by changing the value of various options. Commands which set options are as follows:

1.2.9 Mouse

If the mouse option is on (the default is off), tmux allows mouse events to be bound as keys. The default key bindings allow the mouse to be used to select and resize panes, to copy text and to change window using the status line.

1.2.10 Status line

tmux includes an optional status line which is displayed in the bottom line of each terminal. By default, the status line is enabled and one line in height and contains, from left-to-right: the name of the current session in square brackets; the window list; the title of the active pane in double quotes; and the time and date.

1.2.11 Buffers

Todo.

1.2.12 Hooks

Todo.

1.2.13 Examples

None.

1.2.14 Author

Nicholas Marriott (nicholas.marriott@gmail.com)