Linux "tmux" Command Line Options and Examples
terminal multiplexer

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 reat‐ tached. When tmux is started it creates a new session with a single window and displays it on screen.


Usage:

tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name] [-S socket-path] [command [flags]]




Command Line Options:

-
# Window activity is monitored and activity has been detected.! Window bells are monitored and a bell has occurred in the window.~ The window has been silent for the monitor-silence interval.M The window contains the marked pane.Z The window's active pane is zoomed.The # symbol relates to the monitor-activity window option. The window name is printed in inverted colours ifan alert (bell, activity or silence) is present.The colour and attributes of the status line may be configured, the entire status line using the status-stylesession option and individual windows using the window-status-style window option.The status line is automatically refreshed at interval if it has changed, the interval may be controlled withthe status-interval session option.Commands related to the status line are as follows:command-prompt [-1i] [-I inputs] [-p prompts] [-t target-client] [template]Open the command prompt in a client. This may be used from inside tmux to execute commands interac‐tively.If template is specified, it is used as the command. If present, -I is a comma-separated list of theinitial text for each prompt. If -p is given, prompts is a comma-separated list of prompts which aredisplayed in order; otherwise a single prompt is displayed, constructed from template if it is present,or ‘:’ if not.Before the command is executed, the first occurrence of the string ‘%%’ and all occurrences of ‘%1’ arereplaced by the response to the first prompt, all ‘%2’ are replaced with the response to the secondprompt, and so on for further prompts. Up to nine prompt responses may be replaced (‘%1’ to ‘%9’).‘%%%’ is like ‘%%’ but any quotation marks are escaped.
tmux - ...
-1
makes the prompt only accept one key press, in this case the resulting input is a single character.
tmux -1 ...
-s
n Repeat last searcht Toggle if buffer is taggedT Tag no buffers
tmux -s ...
-t
d Delete selected bufferD Delete tagged buffersf Enter a format to filter itemsO Change sort orderv Toggle previewq Exit modeAfter a buffer is chosen, ‘%%’ is replaced by the buffer name in template and the result executed as acommand. If template is not given, "paste-buffer -b '%%'" is used.
tmux -t ...
-p
requested bracketed paste mode.save-buffer [-a] [-b buffer-name] path(alias: saveb)Save the contents of the specified paste buffer to path. The -a option appends to rather than overwrit‐ing the file.set-buffer [-a] [-b buffer-name] [-n new-buffer-name] data(alias: setb)Set the contents of the specified buffer to data. The -a option appends to rather than overwriting thebuffer. The -n option renames the buffer to new-buffer-name.show-buffer [-b buffer-name](alias: showb)Display the contents of the specified buffer.MISCELLANEOUSMiscellaneous commands are as follows:clock-mode [-t target-pane]Display a large clock.if-shell [-bF] [-t target-pane] shell-command command [command](alias: if)Execute the first command if shell-command returns success or the second command otherwise. Beforebeing executed, shell-command is expanded using the rules specified in the FORMATS section, includingthose relevant to target-pane. With -b, shell-command is run in the background.If -F is given, shell-command is not executed but considered success if neither empty nor zero (afterformats are expanded).lock-server(alias: lock)Lock each client individually by running the command specified by the lock-command option.run-shell [-b] [-t target-pane] shell-command(alias: run)Execute shell-command in the background without creating a window. Before being executed, shell-commandis expanded using the rules specified in the FORMATS section. With -b, the command is run in the back‐ground. After it finishes, any output to stdout is displayed in copy mode (in the pane specified by -tor the current pane if omitted). If the command doesn't return success, the exit status is also dis‐played.wait-for [-L | -S | -U] channel(alias: wait)When used without options, prevents the client from exiting until woken using wait-for -S with the samechannel. When -L is used, the channel is locked and any clients that try to lock the same channel aremade to wait until the channel is unlocked with wait-for -U. This command only works from outside tmux.TERMINFO EXTENSIONStmux understands some unofficial extensions to terminfo(5):Cs, Cr Set the cursor colour. The first takes a single string argument and is used to set the colour; the sec‐ond takes no arguments and restores the default cursor colour. If set, a sequence such as this may beused to change the cursor colour from inside tmux:$ printf '\033]12;red\033\\'Ss, Se Set or reset the cursor style. If set, a sequence such as this may be used to change the cursor to anunderline:$ printf '\033[4 q'If Se is not set, Ss with argument 0 will be used to reset the cursor style instead.Tc Indicate that the terminal supports the ‘direct colour’ RGB escape sequence (for example,\e[38;2;255;255;255m).If supported, this is used for the OSC initialize colour escape sequence (which may be enabled by addingthe ‘initc’ and ‘ccc’ capabilities to the tmux terminfo(5) entry).Ms Store the current buffer in the host terminal's selection (clipboard). See the set-clipboard optionabove and the xterm(1) man page.CONTROL MODEtmux offers a textual interface called control mode. This allows applications to communicate with tmux using asimple text-only protocol.In control mode, a client sends tmux commands or command sequences terminated by newlines on standard input.Each command will produce one block of output on standard output. An output block consists of a %begin linefollowed by the output (which may be empty). The output block ends with a %end or %error. %begin and matching%end or %error have two arguments: an integer time (as seconds from epoch) and command number. For example:%begin 1363006971 20: ksh* (1 panes) [80x24] [layout b25f,80x24,0,0,2] @2 (active)%end 1363006971 2The refresh-client -C command may be used to set the size of a client in control mode.In control mode, tmux outputs notifications. A notification will never occur inside an output block.The following notifications are defined:%client-session-changed client session-id nameThe client is now attached to the session with ID session-id, which is named name.%exit [reason]The tmux client is exiting immediately, either because it is not attached to any session or an erroroccurred. If present, reason describes why the client exited.%layout-change window-id window-layout window-visible-layout window-flagsThe layout of a window with ID window-id changed. The new layout is window-layout. The window's visi‐ble layout is window-visible-layout and the window flags are window-flags.%output pane-id valueA window pane produced output. value escapes non-printable characters and backslash as octal \xxx.%pane-mode-changed pane-idThe pane with ID pane-id has changed mode.%session-changed session-id nameThe client is now attached to the session with ID session-id, which is named name.%session-renamed nameThe current session was renamed to name.%session-window-changed session-id window-idThe session with ID session-id changed its active window to the window with ID window-id.%sessions-changedA session was created or destroyed.%unlinked-window-add window-idThe window with ID window-id was created but is not linked to the current session.%window-add window-idThe window with ID window-id was linked to the current session.%window-close window-idThe window with ID window-id closed.%window-pane-changed window-id pane-idThe active pane in the window with ID window-id changed to the pane with ID pane-id.%window-renamed window-id nameThe window with ID window-id was renamed to name.FILES~/.tmux.conf Default tmux configuration file./etc/tmux.conf System-wide configuration file.EXAMPLESTo create a new tmux session running vi(1):$ tmux new-session viMost commands have a shorter form, known as an alias. For new-session, this is new:$ tmux new viAlternatively, the shortest unambiguous form of a command is accepted. If there are several options, they arelisted:$ tmux nambiguous command: n, could be: new-session, new-window, next-windowWithin an active session, a new window may be created by typing ‘C-b c’ (Ctrl followed by the ‘b’ key followedby the ‘c’ key).Windows may be navigated with: ‘C-b 0’ (to select window 0), ‘C-b 1’ (to select window 1), and so on; ‘C-b n’ toselect the next window; and ‘C-b p’ to select the previous window.A session may be detached using ‘C-b d’ (or by an external event such as ssh(1) disconnection) and reattachedwith:$ tmux attach-sessionTyping ‘C-b ?’ lists the current key bindings in the current window; up and down may be used to navigate thelist or ‘q’ to exit from it.Commands to be run when the tmux server is started may be placed in the ~/.tmux.conf configuration file. Commonexamples include:Changing the default prefix key:set-option -g prefix C-aunbind-key C-bbind-key C-a send-prefixTurning the status line off, or changing its colour:set-option -g status offset-option -g status-style bg=blueSetting other options, such as the default command, or locking after 30 minutes of inactivity:set-option -g default-command "exec /bin/ksh"set-option -g lock-after-time 1800Creating new key bindings:bind-key b set-option statusbind-key / command-prompt "split-window 'exec man %%'"bind-key S command-prompt "new-window -n %1 'ssh %1'"
tmux -p ...