xref: /openbsd-src/usr.bin/tmux/tmux.1 (revision 897fc685943471cf985a0fe38ba076ea6fe74fa5)
1.\" $OpenBSD: tmux.1,v 1.594 2018/04/10 10:48:44 nicm Exp $
2.\"
3.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
14.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
15.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 10 2018 $
18.Dt TMUX 1
19.Os
20.Sh NAME
21.Nm tmux
22.Nd terminal multiplexer
23.Sh SYNOPSIS
24.Nm tmux
25.Bk -words
26.Op Fl 2Cluv
27.Op Fl c Ar shell-command
28.Op Fl f Ar file
29.Op Fl L Ar socket-name
30.Op Fl S Ar socket-path
31.Op Ar command Op Ar flags
32.Ek
33.Sh DESCRIPTION
34.Nm
35is a terminal multiplexer:
36it enables a number of terminals to be created, accessed, and
37controlled from a single screen.
38.Nm
39may be detached from a screen
40and continue running in the background,
41then later reattached.
42.Pp
43When
44.Nm
45is started it creates a new
46.Em session
47with a single
48.Em window
49and displays it on screen.
50A status line at the bottom of the screen
51shows information on the current session
52and is used to enter interactive commands.
53.Pp
54A session is a single collection of
55.Em pseudo terminals
56under the management of
57.Nm .
58Each session has one or more
59windows linked to it.
60A window occupies the entire screen
61and may be split into rectangular panes,
62each of which is a separate pseudo terminal
63(the
64.Xr pty 4
65manual page documents the technical details of pseudo terminals).
66Any number of
67.Nm
68instances may connect to the same session,
69and any number of windows may be present in the same session.
70Once all sessions are killed,
71.Nm
72exits.
73.Pp
74Each session is persistent and will survive accidental disconnection
75(such as
76.Xr ssh 1
77connection timeout) or intentional detaching (with the
78.Ql C-b d
79key strokes).
80.Nm
81may be reattached using:
82.Pp
83.Dl $ tmux attach
84.Pp
85In
86.Nm ,
87a session is displayed on screen by a
88.Em client
89and all sessions are managed by a single
90.Em server .
91The server and each client are separate processes which communicate through a
92socket in
93.Pa /tmp .
94.Pp
95The options are as follows:
96.Bl -tag -width "XXXXXXXXXXXX"
97.It Fl 2
98Force
99.Nm
100to assume the terminal supports 256 colours.
101.It Fl C
102Start in control mode (see the
103.Sx CONTROL MODE
104section).
105Given twice
106.Xo ( Fl CC ) Xc
107disables echo.
108.It Fl c Ar shell-command
109Execute
110.Ar shell-command
111using the default shell.
112If necessary, the
113.Nm
114server will be started to retrieve the
115.Ic default-shell
116option.
117This option is for compatibility with
118.Xr sh 1
119when
120.Nm
121is used as a login shell.
122.It Fl f Ar file
123Specify an alternative configuration file.
124By default,
125.Nm
126loads the system configuration file from
127.Pa /etc/tmux.conf ,
128if present, then looks for a user configuration file at
129.Pa ~/.tmux.conf .
130.Pp
131The configuration file is a set of
132.Nm
133commands which are executed in sequence when the server is first started.
134.Nm
135loads configuration files once when the server process has started.
136The
137.Ic source-file
138command may be used to load a file later.
139.Pp
140.Nm
141shows any error messages from commands in configuration files in the first
142session created, and continues to process the rest of the configuration file.
143.It Fl L Ar socket-name
144.Nm
145stores the server socket in a directory under
146.Ev TMUX_TMPDIR
147or
148.Pa /tmp
149if it is unset.
150The default socket is named
151.Em default .
152This option allows a different socket name to be specified, allowing several
153independent
154.Nm
155servers to be run.
156Unlike
157.Fl S
158a full path is not necessary: the sockets are all created in the same
159directory.
160.Pp
161If the socket is accidentally removed, the
162.Dv SIGUSR1
163signal may be sent to the
164.Nm
165server process to recreate it (note that this will fail if any parent
166directories are missing).
167.It Fl l
168Behave as a login shell.
169This flag currently has no effect and is for compatibility with other shells
170when using tmux as a login shell.
171.It Fl S Ar socket-path
172Specify a full alternative path to the server socket.
173If
174.Fl S
175is specified, the default socket directory is not used and any
176.Fl L
177flag is ignored.
178.It Fl u
179When starting,
180.Nm
181looks for the
182.Ev LC_ALL ,
183.Ev LC_CTYPE
184and
185.Ev LANG
186environment variables: if the first found contains
187.Ql UTF-8 ,
188then the terminal is assumed to support UTF-8.
189This is not always correct: the
190.Fl u
191flag explicitly informs
192.Nm
193that UTF-8 is supported.
194.Pp
195Note that
196.Nm
197itself always accepts UTF-8; this controls whether it will send UTF-8
198characters to the terminal it is running (if not, they are replaced by
199.Ql _ ) .
200.It Fl v
201Request verbose logging.
202Log messages will be saved into
203.Pa tmux-client-PID.log
204and
205.Pa tmux-server-PID.log
206files in the current directory, where
207.Em PID
208is the PID of the server or client process.
209.Pp
210If
211.Fl v
212is specified twice, an additional
213.Pa tmux-out-PID.log
214file is generated with a copy of everything
215.Nm
216writes to the terminal.
217.Pp
218The
219.Dv SIGUSR2
220signal may be sent to the
221.Nm
222server process to toggle logging between on (as if
223.Fl v
224was given) and off.
225.It Ar command Op Ar flags
226This specifies one of a set of commands used to control
227.Nm ,
228as described in the following sections.
229If no commands are specified, the
230.Ic new-session
231command is assumed.
232.El
233.Sh KEY BINDINGS
234.Nm
235may be controlled from an attached client by using a key combination of a
236prefix key,
237.Ql C-b
238(Ctrl-b) by default, followed by a command key.
239.Pp
240The default command key bindings are:
241.Pp
242.Bl -tag -width "XXXXXXXXXX" -offset indent -compact
243.It C-b
244Send the prefix key (C-b) through to the application.
245.It C-o
246Rotate the panes in the current window forwards.
247.It C-z
248Suspend the
249.Nm
250client.
251.It !
252Break the current pane out of the window.
253.It \&"
254Split the current pane into two, top and bottom.
255.It #
256List all paste buffers.
257.It $
258Rename the current session.
259.It %
260Split the current pane into two, left and right.
261.It &
262Kill the current window.
263.It '
264Prompt for a window index to select.
265.It \&(
266Switch the attached client to the previous session.
267.It \&)
268Switch the attached client to the next session.
269.It ,
270Rename the current window.
271.It -
272Delete the most recently copied buffer of text.
273.It .
274Prompt for an index to move the current window.
275.It 0 to 9
276Select windows 0 to 9.
277.It :
278Enter the
279.Nm
280command prompt.
281.It ;
282Move to the previously active pane.
283.It =
284Choose which buffer to paste interactively from a list.
285.It \&?
286List all key bindings.
287.It D
288Choose a client to detach.
289.It L
290Switch the attached client back to the last session.
291.It \&[
292Enter copy mode to copy text or view the history.
293.It \&]
294Paste the most recently copied buffer of text.
295.It c
296Create a new window.
297.It d
298Detach the current client.
299.It f
300Prompt to search for text in open windows.
301.It i
302Display some information about the current window.
303.It l
304Move to the previously selected window.
305.It n
306Change to the next window.
307.It o
308Select the next pane in the current window.
309.It p
310Change to the previous window.
311.It q
312Briefly display pane indexes.
313.It r
314Force redraw of the attached client.
315.It m
316Mark the current pane (see
317.Ic select-pane
318.Fl m ) .
319.It M
320Clear the marked pane.
321.It s
322Select a new session for the attached client interactively.
323.It t
324Show the time.
325.It w
326Choose the current window interactively.
327.It x
328Kill the current pane.
329.It z
330Toggle zoom state of the current pane.
331.It {
332Swap the current pane with the previous pane.
333.It }
334Swap the current pane with the next pane.
335.It ~
336Show previous messages from
337.Nm ,
338if any.
339.It Page Up
340Enter copy mode and scroll one page up.
341.It Up, Down
342.It Left, Right
343Change to the pane above, below, to the left, or to the right of the current
344pane.
345.It M-1 to M-5
346Arrange panes in one of the five preset layouts: even-horizontal,
347even-vertical, main-horizontal, main-vertical, or tiled.
348.It Space
349Arrange the current window in the next preset layout.
350.It M-n
351Move to the next window with a bell or activity marker.
352.It M-o
353Rotate the panes in the current window backwards.
354.It M-p
355Move to the previous window with a bell or activity marker.
356.It C-Up, C-Down
357.It C-Left, C-Right
358Resize the current pane in steps of one cell.
359.It M-Up, M-Down
360.It M-Left, M-Right
361Resize the current pane in steps of five cells.
362.El
363.Pp
364Key bindings may be changed with the
365.Ic bind-key
366and
367.Ic unbind-key
368commands.
369.Sh COMMANDS
370This section contains a list of the commands supported by
371.Nm .
372Most commands accept the optional
373.Fl t
374(and sometimes
375.Fl s )
376argument with one of
377.Ar target-client ,
378.Ar target-session
379.Ar target-window ,
380or
381.Ar target-pane .
382These specify the client, session, window or pane which a command should affect.
383.Pp
384.Ar target-client
385should be the name of the client,
386typically the
387.Xr pty 4
388file to which the client is connected, for example either of
389.Pa /dev/ttyp1
390or
391.Pa ttyp1
392for the client attached to
393.Pa /dev/ttyp1 .
394If no client is specified,
395.Nm
396attempts to work out the client currently in use; if that fails, an error is
397reported.
398Clients may be listed with the
399.Ic list-clients
400command.
401.Pp
402.Ar target-session
403is tried as, in order:
404.Bl -enum -offset Ds
405.It
406A session ID prefixed with a $.
407.It
408An exact name of a session (as listed by the
409.Ic list-sessions
410command).
411.It
412The start of a session name, for example
413.Ql mysess
414would match a session named
415.Ql mysession .
416.It
417An
418.Xr fnmatch 3
419pattern which is matched against the session name.
420.El
421.Pp
422If the session name is prefixed with an
423.Ql = ,
424only an exact match is accepted (so
425.Ql =mysess
426will only match exactly
427.Ql mysess ,
428not
429.Ql mysession ) .
430.Pp
431If a single session is found, it is used as the target session; multiple matches
432produce an error.
433If a session is omitted, the current session is used if available; if no
434current session is available, the most recently used is chosen.
435.Pp
436.Ar target-window
437(or
438.Ar src-window
439or
440.Ar dst-window )
441specifies a window in the form
442.Em session Ns \&: Ns Em window .
443.Em session
444follows the same rules as for
445.Ar target-session ,
446and
447.Em window
448is looked for in order as:
449.Bl -enum -offset Ds
450.It
451A special token, listed below.
452.It
453A window index, for example
454.Ql mysession:1
455is window 1 in session
456.Ql mysession .
457.It
458A window ID, such as @1.
459.It
460An exact window name, such as
461.Ql mysession:mywindow .
462.It
463The start of a window name, such as
464.Ql mysession:mywin .
465.It
466As an
467.Xr fnmatch 3
468pattern matched against the window name.
469.El
470.Pp
471Like sessions, a
472.Ql =
473prefix will do an exact match only.
474An empty window name specifies the next unused index if appropriate (for
475example the
476.Ic new-window
477and
478.Ic link-window
479commands)
480otherwise the current window in
481.Em session
482is chosen.
483.Pp
484The following special tokens are available to indicate particular windows.
485Each has a single-character alternative form.
486.Bl -column "XXXXXXXXXX" "X"
487.It Sy "Token" Ta Sy "" Ta Sy "Meaning"
488.It Li "{start}" Ta "^" Ta "The lowest-numbered window"
489.It Li "{end}" Ta "$" Ta "The highest-numbered window"
490.It Li "{last}" Ta "!" Ta "The last (previously current) window"
491.It Li "{next}" Ta "+" Ta "The next window by number"
492.It Li "{previous}" Ta "-" Ta "The previous window by number"
493.El
494.Pp
495.Ar target-pane
496(or
497.Ar src-pane
498or
499.Ar dst-pane )
500may be a pane ID or takes a similar form to
501.Ar target-window
502but with the optional addition of a period followed by a pane index or pane ID,
503for example:
504.Ql mysession:mywindow.1 .
505If the pane index is omitted, the currently active pane in the specified
506window is used.
507The following special tokens are available for the pane index:
508.Bl -column "XXXXXXXXXXXXXX" "X"
509.It Sy "Token" Ta Sy "" Ta Sy "Meaning"
510.It Li "{last}" Ta "!" Ta "The last (previously active) pane"
511.It Li "{next}" Ta "+" Ta "The next pane by number"
512.It Li "{previous}" Ta "-" Ta "The previous pane by number"
513.It Li "{top}" Ta "" Ta "The top pane"
514.It Li "{bottom}" Ta "" Ta "The bottom pane"
515.It Li "{left}" Ta "" Ta "The leftmost pane"
516.It Li "{right}" Ta "" Ta "The rightmost pane"
517.It Li "{top-left}" Ta "" Ta "The top-left pane"
518.It Li "{top-right}" Ta "" Ta "The top-right pane"
519.It Li "{bottom-left}" Ta "" Ta "The bottom-left pane"
520.It Li "{bottom-right}" Ta "" Ta "The bottom-right pane"
521.It Li "{up-of}" Ta "" Ta "The pane above the active pane"
522.It Li "{down-of}" Ta "" Ta "The pane below the active pane"
523.It Li "{left-of}" Ta "" Ta "The pane to the left of the active pane"
524.It Li "{right-of}" Ta "" Ta "The pane to the right of the active pane"
525.El
526.Pp
527The tokens
528.Ql +
529and
530.Ql -
531may be followed by an offset, for example:
532.Bd -literal -offset indent
533select-window -t:+2
534.Ed
535.Pp
536In addition,
537.Em target-session ,
538.Em target-window
539or
540.Em target-pane
541may consist entirely of the token
542.Ql {mouse}
543(alternative form
544.Ql = )
545to specify the most recent mouse event
546(see the
547.Sx MOUSE SUPPORT
548section)
549or
550.Ql {marked}
551(alternative form
552.Ql ~ )
553to specify the marked pane (see
554.Ic select-pane
555.Fl m ) .
556.Pp
557Sessions, window and panes are each numbered with a unique ID; session IDs are
558prefixed with a
559.Ql $ ,
560windows with a
561.Ql @ ,
562and panes with a
563.Ql % .
564These are unique and are unchanged for the life of the session, window or pane
565in the
566.Nm
567server.
568The pane ID is passed to the child process of the pane in the
569.Ev TMUX_PANE
570environment variable.
571IDs may be displayed using the
572.Ql session_id ,
573.Ql window_id ,
574or
575.Ql pane_id
576formats (see the
577.Sx FORMATS
578section) and the
579.Ic display-message ,
580.Ic list-sessions ,
581.Ic list-windows
582or
583.Ic list-panes
584commands.
585.Pp
586.Ar shell-command
587arguments are
588.Xr sh 1
589commands.
590This may be a single argument passed to the shell, for example:
591.Bd -literal -offset indent
592new-window 'vi /etc/passwd'
593.Ed
594.Pp
595Will run:
596.Bd -literal -offset indent
597/bin/sh -c 'vi /etc/passwd'
598.Ed
599.Pp
600Additionally, the
601.Ic new-window ,
602.Ic new-session ,
603.Ic split-window ,
604.Ic respawn-window
605and
606.Ic respawn-pane
607commands allow
608.Ar shell-command
609to be given as multiple arguments and executed directly (without
610.Ql sh -c ) .
611This can avoid issues with shell quoting.
612For example:
613.Bd -literal -offset indent
614$ tmux new-window vi /etc/passwd
615.Ed
616.Pp
617Will run
618.Xr vi 1
619directly without invoking the shell.
620.Pp
621.Ar command
622.Op Ar arguments
623refers to a
624.Nm
625command, passed with the command and arguments separately, for example:
626.Bd -literal -offset indent
627bind-key F1 set-window-option force-width 81
628.Ed
629.Pp
630Or if using
631.Xr sh 1 :
632.Bd -literal -offset indent
633$ tmux bind-key F1 set-window-option force-width 81
634.Ed
635.Pp
636Multiple commands may be specified together as part of a
637.Em command sequence .
638Each command should be separated by spaces and a semicolon;
639commands are executed sequentially from left to right and
640lines ending with a backslash continue on to the next line,
641except when escaped by another backslash.
642A literal semicolon may be included by escaping it with a backslash (for
643example, when specifying a command sequence to
644.Ic bind-key ) .
645.Pp
646Example
647.Nm
648commands include:
649.Bd -literal -offset indent
650refresh-client -t/dev/ttyp2
651
652rename-session -tfirst newname
653
654set-window-option -t:0 monitor-activity on
655
656new-window ; split-window -d
657
658bind-key R source-file ~/.tmux.conf \e; \e
659	display-message "source-file done"
660.Ed
661.Pp
662Or from
663.Xr sh 1 :
664.Bd -literal -offset indent
665$ tmux kill-window -t :1
666
667$ tmux new-window \e; split-window -d
668
669$ tmux new-session -d 'vi /etc/passwd' \e; split-window -d \e; attach
670.Ed
671.Sh CLIENTS AND SESSIONS
672The
673.Nm
674server manages clients, sessions, windows and panes.
675Clients are attached to sessions to interact with them, either
676when they are created with the
677.Ic new-session
678command, or later with the
679.Ic attach-session
680command.
681Each session has one or more windows
682.Em linked
683into it.
684Windows may be linked to multiple sessions and are made up of one or
685more panes,
686each of which contains a pseudo terminal.
687Commands for creating, linking and otherwise manipulating windows
688are covered
689in the
690.Sx WINDOWS AND PANES
691section.
692.Pp
693The following commands are available to manage clients and sessions:
694.Bl -tag -width Ds
695.It Xo Ic attach-session
696.Op Fl dEr
697.Op Fl c Ar working-directory
698.Op Fl t Ar target-session
699.Xc
700.D1 (alias: Ic attach )
701If run from outside
702.Nm ,
703create a new client in the current terminal and attach it to
704.Ar target-session .
705If used from inside, switch the current client.
706If
707.Fl d
708is specified, any other clients attached to the session are detached.
709.Fl r
710signifies the client is read-only (only keys bound to the
711.Ic detach-client
712or
713.Ic switch-client
714commands have any effect)
715.Pp
716If no server is started,
717.Ic attach-session
718will attempt to start it; this will fail unless sessions are created in the
719configuration file.
720.Pp
721The
722.Ar target-session
723rules for
724.Ic attach-session
725are slightly adjusted: if
726.Nm
727needs to select the most recently used session, it will prefer the most
728recently used
729.Em unattached
730session.
731.Pp
732.Fl c
733will set the session working directory (used for new windows) to
734.Ar working-directory .
735.Pp
736If
737.Fl E
738is used, the
739.Ic update-environment
740option will not be applied.
741.It Xo Ic detach-client
742.Op Fl aP
743.Op Fl E Ar shell-command
744.Op Fl s Ar target-session
745.Op Fl t Ar target-client
746.Xc
747.D1 (alias: Ic detach )
748Detach the current client if bound to a key, the client specified with
749.Fl t ,
750or all clients currently attached to the session specified by
751.Fl s .
752The
753.Fl a
754option kills all but the client given with
755.Fl t .
756If
757.Fl P
758is given, send SIGHUP to the parent process of the client, typically causing it
759to exit.
760With
761.Fl E ,
762run
763.Ar shell-command
764to replace the client.
765.It Ic has-session Op Fl t Ar target-session
766.D1 (alias: Ic has )
767Report an error and exit with 1 if the specified session does not exist.
768If it does exist, exit with 0.
769.It Ic kill-server
770Kill the
771.Nm
772server and clients and destroy all sessions.
773.It Xo Ic kill-session
774.Op Fl aC
775.Op Fl t Ar target-session
776.Xc
777Destroy the given session, closing any windows linked to it and no other
778sessions, and detaching all clients attached to it.
779If
780.Fl a
781is given, all sessions but the specified one is killed.
782The
783.Fl C
784flag clears alerts (bell, activity, or silence) in all windows linked to the
785session.
786.It Xo Ic list-clients
787.Op Fl F Ar format
788.Op Fl t Ar target-session
789.Xc
790.D1 (alias: Ic lsc )
791List all clients attached to the server.
792For the meaning of the
793.Fl F
794flag, see the
795.Sx FORMATS
796section.
797If
798.Ar target-session
799is specified, list only clients connected to that session.
800.It Xo Ic list-commands
801.Op Fl F Ar format
802.Xc
803.D1 (alias: Ic lscm )
804List the syntax of all commands supported by
805.Nm .
806.It Ic list-sessions Op Fl F Ar format
807.D1 (alias: Ic ls )
808List all sessions managed by the server.
809For the meaning of the
810.Fl F
811flag, see the
812.Sx FORMATS
813section.
814.It Ic lock-client Op Fl t Ar target-client
815.D1 (alias: Ic lockc )
816Lock
817.Ar target-client ,
818see the
819.Ic lock-server
820command.
821.It Ic lock-session Op Fl t Ar target-session
822.D1 (alias: Ic locks )
823Lock all clients attached to
824.Ar target-session .
825.It Xo Ic new-session
826.Op Fl AdDEP
827.Op Fl c Ar start-directory
828.Op Fl F Ar format
829.Op Fl n Ar window-name
830.Op Fl s Ar session-name
831.Op Fl t Ar group-name
832.Op Fl x Ar width
833.Op Fl y Ar height
834.Op Ar shell-command
835.Xc
836.D1 (alias: Ic new )
837Create a new session with name
838.Ar session-name .
839.Pp
840The new session is attached to the current terminal unless
841.Fl d
842is given.
843.Ar window-name
844and
845.Ar shell-command
846are the name of and shell command to execute in the initial window.
847With
848.Fl d ,
849the initial size is 80 x 24;
850.Fl x
851and
852.Fl y
853can be used to specify a different size.
854.Pp
855If run from a terminal, any
856.Xr termios 4
857special characters are saved and used for new windows in the new session.
858.Pp
859The
860.Fl A
861flag makes
862.Ic new-session
863behave like
864.Ic attach-session
865if
866.Ar session-name
867already exists; in this case,
868.Fl D
869behaves like
870.Fl d
871to
872.Ic attach-session .
873.Pp
874If
875.Fl t
876is given, it specifies a
877.Ic session group .
878Sessions in the same group share the same set of windows - new windows are
879linked to all sessions in the group and any windows closed removed from all
880sessions.
881The current and previous window and any session options remain independent and
882any session in a group may be killed without affecting the others.
883The
884.Ar group-name
885argument may be:
886.Bl -enum -width Ds
887.It
888the name of an existing group, in which case the new session is added to that
889group;
890.It
891the name of an existing session - the new session is added to the same group
892as that session, creating a new group if necessary;
893.It
894the name for a new group containing only the new session.
895.El
896.Pp
897.Fl n
898and
899.Ar shell-command
900are invalid if
901.Fl t
902is used.
903.Pp
904The
905.Fl P
906option prints information about the new session after it has been created.
907By default, it uses the format
908.Ql #{session_name}:
909but a different format may be specified with
910.Fl F .
911.Pp
912If
913.Fl E
914is used, the
915.Ic update-environment
916option will not be applied.
917.It Xo Ic refresh-client
918.Op Fl C Ar width,height
919.Op Fl S
920.Op Fl t Ar target-client
921.Xc
922.D1 (alias: Ic refresh )
923Refresh the current client if bound to a key, or a single client if one is given
924with
925.Fl t .
926If
927.Fl S
928is specified, only update the client's status line.
929.Pp
930.Fl C
931sets the width and height of a control client.
932.It Xo Ic rename-session
933.Op Fl t Ar target-session
934.Ar new-name
935.Xc
936.D1 (alias: Ic rename )
937Rename the session to
938.Ar new-name .
939.It Xo Ic show-messages
940.Op Fl JT
941.Op Fl t Ar target-client
942.Xc
943.D1 (alias: Ic showmsgs )
944Show client messages or server information.
945Any messages displayed on the status line are saved in a per-client message
946log, up to a maximum of the limit set by the
947.Ar message-limit
948server option.
949With
950.Fl t ,
951display the log for
952.Ar target-client .
953.Fl J
954and
955.Fl T
956show debugging information about jobs and terminals.
957.It Xo Ic source-file
958.Op Fl q
959.Ar path
960.Xc
961.D1 (alias: Ic source )
962Execute commands from
963.Ar path
964(which may be a
965.Xr glob 3
966pattern).
967If
968.Fl q
969is given, no error will be returned if
970.Ar path
971does not exist.
972.Pp
973Within a configuration file, commands may be made conditional by surrounding
974them with
975.Em %if
976and
977.Em %endif
978lines.
979Additional
980.Em %elif
981and
982.Em %else
983lines may also be used.
984The argument to
985.Em %if
986and
987.Em %elif
988is expanded as a format and if it evaluates to false (zero or empty),
989subsequent lines are ignored until the next
990.Em %elif ,
991.Em %else
992or
993.Em %endif .
994For example:
995.Bd -literal -offset indent
996%if #{==:#{host},myhost}
997set -g status-style bg=red
998%elif #{==:#{host},myotherhost}
999set -g status-style bg=green
1000%else
1001set -g status-style bg=blue
1002%endif
1003.Ed
1004.Pp
1005Will change the status line to red if running on
1006.Ql myhost ,
1007green if running on
1008.Ql myotherhost ,
1009or blue if running on another host.
1010.It Ic start-server
1011.D1 (alias: Ic start )
1012Start the
1013.Nm
1014server, if not already running, without creating any sessions.
1015.It Xo Ic suspend-client
1016.Op Fl t Ar target-client
1017.Xc
1018.D1 (alias: Ic suspendc )
1019Suspend a client by sending
1020.Dv SIGTSTP
1021(tty stop).
1022.It Xo Ic switch-client
1023.Op Fl Elnpr
1024.Op Fl c Ar target-client
1025.Op Fl t Ar target-session
1026.Op Fl T Ar key-table
1027.Xc
1028.D1 (alias: Ic switchc )
1029Switch the current session for client
1030.Ar target-client
1031to
1032.Ar target-session .
1033If
1034.Fl l ,
1035.Fl n
1036or
1037.Fl p
1038is used, the client is moved to the last, next or previous session
1039respectively.
1040.Fl r
1041toggles whether a client is read-only (see the
1042.Ic attach-session
1043command).
1044.Pp
1045If
1046.Fl E
1047is used,
1048.Ic update-environment
1049option will not be applied.
1050.Pp
1051.Fl T
1052sets the client's key table; the next key from the client will be interpreted from
1053.Ar key-table .
1054This may be used to configure multiple prefix keys, or to bind commands to
1055sequences of keys.
1056For example, to make typing
1057.Ql abc
1058run the
1059.Ic list-keys
1060command:
1061.Bd -literal -offset indent
1062bind-key -Ttable2 c list-keys
1063bind-key -Ttable1 b switch-client -Ttable2
1064bind-key -Troot   a switch-client -Ttable1
1065.Ed
1066.El
1067.Sh WINDOWS AND PANES
1068A
1069.Nm
1070window may be in one of two modes.
1071The default permits direct access to the terminal attached to the window.
1072The other is copy mode, which permits a section of a window or its
1073history to be copied to a
1074.Em paste buffer
1075for later insertion into another window.
1076This mode is entered with the
1077.Ic copy-mode
1078command, bound to
1079.Ql \&[
1080by default.
1081It is also entered when a command that produces output, such as
1082.Ic list-keys ,
1083is executed from a key binding.
1084.Pp
1085Commands are sent to copy mode using the
1086.Fl X
1087flag to the
1088.Ic send-keys
1089command.
1090When a key is pressed, copy mode automatically uses one of two key tables,
1091depending on the
1092.Ic mode-keys
1093option:
1094.Ic copy-mode
1095for emacs, or
1096.Ic copy-mode-vi
1097for vi.
1098Key tables may be viewed with the
1099.Ic list-keys
1100command.
1101.Pp
1102The following commands are supported in copy mode:
1103.Bl -column "CommandXXXXXXXXXXXXXXXXXXXXXXXXXX" "viXXXXXXXXXX" "emacs" -offset indent
1104.It Sy "Command" Ta Sy "vi" Ta Sy "emacs"
1105.It Li "append-selection" Ta "" Ta ""
1106.It Li "append-selection-and-cancel" Ta "A" Ta ""
1107.It Li "back-to-indentation" Ta "^" Ta "M-m"
1108.It Li "begin-selection" Ta "Space" Ta "C-Space"
1109.It Li "bottom-line" Ta "L" Ta ""
1110.It Li "cancel" Ta "q" Ta "Escape"
1111.It Li "clear-selection" Ta "Escape" Ta "C-g"
1112.It Li "copy-end-of-line" Ta "D" Ta "C-k"
1113.It Li "copy-line" Ta "" Ta ""
1114.It Li "copy-pipe <command>" Ta "" Ta ""
1115.It Li "copy-pipe-and-cancel <command>" Ta "" Ta ""
1116.It Li "copy-selection" Ta "" Ta ""
1117.It Li "copy-selection-and-cancel" Ta "Enter" Ta "M-w"
1118.It Li "cursor-down" Ta "j" Ta "Down"
1119.It Li "cursor-left" Ta "h" Ta "Left"
1120.It Li "cursor-right" Ta "l" Ta "Right"
1121.It Li "cursor-up" Ta "k" Ta "Up"
1122.It Li "end-of-line" Ta "$" Ta "C-e"
1123.It Li "goto-line <line>" Ta ":" Ta "g"
1124.It Li "halfpage-down" Ta "C-d" Ta "M-Down"
1125.It Li "halfpage-down-and-cancel" Ta "" Ta ""
1126.It Li "halfpage-up" Ta "C-u" Ta "M-Up"
1127.It Li "history-bottom" Ta "G" Ta "M->"
1128.It Li "history-top" Ta "g" Ta "M-<"
1129.It Li "jump-again" Ta ";" Ta ";"
1130.It Li "jump-backward <to>" Ta "F" Ta "F"
1131.It Li "jump-forward <to>" Ta "f" Ta "f"
1132.It Li "jump-reverse" Ta "," Ta ","
1133.It Li "jump-to-backward <to>" Ta "T" Ta ""
1134.It Li "jump-to-forward <to>" Ta "t" Ta ""
1135.It Li "middle-line" Ta "M" Ta "M-r"
1136.It Li "next-paragraph" Ta "}" Ta "M-}"
1137.It Li "next-space" Ta "W" Ta ""
1138.It Li "next-space-end" Ta "E" Ta ""
1139.It Li "next-word" Ta "w" Ta ""
1140.It Li "next-word-end" Ta "e" Ta "M-f"
1141.It Li "other-end" Ta "o" Ta ""
1142.It Li "page-down" Ta "C-f" Ta "PageDown"
1143.It Li "page-down-and-cancel" Ta "" Ta ""
1144.It Li "page-up" Ta "C-b" Ta "PageUp"
1145.It Li "previous-paragraph" Ta "{" Ta "M-{"
1146.It Li "previous-space" Ta "B" Ta ""
1147.It Li "previous-word" Ta "b" Ta "M-b"
1148.It Li "rectangle-toggle" Ta "v" Ta "R"
1149.It Li "scroll-down" Ta "C-e" Ta "C-Down"
1150.It Li "scroll-down-and-cancel" Ta "" Ta ""
1151.It Li "scroll-up" Ta "C-y" Ta "C-Up"
1152.It Li "search-again" Ta "n" Ta "n"
1153.It Li "search-backward <for>" Ta "?" Ta ""
1154.It Li "search-forward <for>" Ta "/" Ta ""
1155.It Li "search-backward-incremental <for>" Ta "" Ta "C-r"
1156.It Li "search-forward-incremental <for>" Ta "" Ta "C-s"
1157.It Li "search-reverse" Ta "N" Ta "N"
1158.It Li "select-line" Ta "V" Ta ""
1159.It Li "start-of-line" Ta "0" Ta "C-a"
1160.It Li "stop-selection" Ta "" Ta ""
1161.It Li "top-line" Ta "H" Ta "M-R"
1162.El
1163.Pp
1164The
1165.Ql -and-cancel
1166variants of some commands exit copy mode after they have completed (for copy
1167commands) or when the cursor reaches the bottom (for scrolling commands).
1168.Pp
1169The next and previous word keys use space and the
1170.Ql - ,
1171.Ql _
1172and
1173.Ql @
1174characters as word delimiters by default, but this can be adjusted by
1175setting the
1176.Em word-separators
1177session option.
1178Next word moves to the start of the next word, next word end to the end of the
1179next word and previous word to the start of the previous word.
1180The three next and previous space keys work similarly but use a space alone as
1181the word separator.
1182.Pp
1183The jump commands enable quick movement within a line.
1184For instance, typing
1185.Ql f
1186followed by
1187.Ql /
1188will move the cursor to the next
1189.Ql /
1190character on the current line.
1191A
1192.Ql \&;
1193will then jump to the next occurrence.
1194.Pp
1195Commands in copy mode may be prefaced by an optional repeat count.
1196With vi key bindings, a prefix is entered using the number keys; with
1197emacs, the Alt (meta) key and a number begins prefix entry.
1198.Pp
1199The synopsis for the
1200.Ic copy-mode
1201command is:
1202.Bl -tag -width Ds
1203.It Xo Ic copy-mode
1204.Op Fl Meu
1205.Op Fl t Ar target-pane
1206.Xc
1207Enter copy mode.
1208The
1209.Fl u
1210option scrolls one page up.
1211.Fl M
1212begins a mouse drag (only valid if bound to a mouse key binding, see
1213.Sx MOUSE SUPPORT ) .
1214.Fl e
1215specifies that scrolling to the bottom of the history (to the visible screen)
1216should exit copy mode.
1217While in copy mode, pressing a key other than those used for scrolling will
1218disable this behaviour.
1219This is intended to allow fast scrolling through a pane's history, for
1220example with:
1221.Bd -literal -offset indent
1222bind PageUp copy-mode -eu
1223.Ed
1224.El
1225.Pp
1226Each window displayed by
1227.Nm
1228may be split into one or more
1229.Em panes ;
1230each pane takes up a certain area of the display and is a separate terminal.
1231A window may be split into panes using the
1232.Ic split-window
1233command.
1234Windows may be split horizontally (with the
1235.Fl h
1236flag) or vertically.
1237Panes may be resized with the
1238.Ic resize-pane
1239command (bound to
1240.Ql C-Up ,
1241.Ql C-Down
1242.Ql C-Left
1243and
1244.Ql C-Right
1245by default), the current pane may be changed with the
1246.Ic select-pane
1247command and the
1248.Ic rotate-window
1249and
1250.Ic swap-pane
1251commands may be used to swap panes without changing their position.
1252Panes are numbered beginning from zero in the order they are created.
1253.Pp
1254A number of preset
1255.Em layouts
1256are available.
1257These may be selected with the
1258.Ic select-layout
1259command or cycled with
1260.Ic next-layout
1261(bound to
1262.Ql Space
1263by default); once a layout is chosen, panes within it may be moved and resized
1264as normal.
1265.Pp
1266The following layouts are supported:
1267.Bl -tag -width Ds
1268.It Ic even-horizontal
1269Panes are spread out evenly from left to right across the window.
1270.It Ic even-vertical
1271Panes are spread evenly from top to bottom.
1272.It Ic main-horizontal
1273A large (main) pane is shown at the top of the window and the remaining panes
1274are spread from left to right in the leftover space at the bottom.
1275Use the
1276.Em main-pane-height
1277window option to specify the height of the top pane.
1278.It Ic main-vertical
1279Similar to
1280.Ic main-horizontal
1281but the large pane is placed on the left and the others spread from top to
1282bottom along the right.
1283See the
1284.Em main-pane-width
1285window option.
1286.It Ic tiled
1287Panes are spread out as evenly as possible over the window in both rows and
1288columns.
1289.El
1290.Pp
1291In addition,
1292.Ic select-layout
1293may be used to apply a previously used layout - the
1294.Ic list-windows
1295command displays the layout of each window in a form suitable for use with
1296.Ic select-layout .
1297For example:
1298.Bd -literal -offset indent
1299$ tmux list-windows
13000: ksh [159x48]
1301    layout: bb62,159x48,0,0{79x48,0,0,79x48,80,0}
1302$ tmux select-layout bb62,159x48,0,0{79x48,0,0,79x48,80,0}
1303.Ed
1304.Pp
1305.Nm
1306automatically adjusts the size of the layout for the current window size.
1307Note that a layout cannot be applied to a window with more panes than that
1308from which the layout was originally defined.
1309.Pp
1310Commands related to windows and panes are as follows:
1311.Bl -tag -width Ds
1312.It Xo Ic break-pane
1313.Op Fl dP
1314.Op Fl F Ar format
1315.Op Fl n Ar window-name
1316.Op Fl s Ar src-pane
1317.Op Fl t Ar dst-window
1318.Xc
1319.D1 (alias: Ic breakp )
1320Break
1321.Ar src-pane
1322off from its containing window to make it the only pane in
1323.Ar dst-window .
1324If
1325.Fl d
1326is given, the new window does not become the current window.
1327The
1328.Fl P
1329option prints information about the new window after it has been created.
1330By default, it uses the format
1331.Ql #{session_name}:#{window_index}
1332but a different format may be specified with
1333.Fl F .
1334.It Xo Ic capture-pane
1335.Op Fl aepPqCJ
1336.Op Fl b Ar buffer-name
1337.Op Fl E Ar end-line
1338.Op Fl S Ar start-line
1339.Op Fl t Ar target-pane
1340.Xc
1341.D1 (alias: Ic capturep )
1342Capture the contents of a pane.
1343If
1344.Fl p
1345is given, the output goes to stdout, otherwise to the buffer specified with
1346.Fl b
1347or a new buffer if omitted.
1348If
1349.Fl a
1350is given, the alternate screen is used, and the history is not accessible.
1351If no alternate screen exists, an error will be returned unless
1352.Fl q
1353is given.
1354If
1355.Fl e
1356is given, the output includes escape sequences for text and background
1357attributes.
1358.Fl C
1359also escapes non-printable characters as octal \exxx.
1360.Fl J
1361joins wrapped lines and preserves trailing spaces at each line's end.
1362.Fl P
1363captures only any output that the pane has received that is the beginning of an
1364as-yet incomplete escape sequence.
1365.Pp
1366.Fl S
1367and
1368.Fl E
1369specify the starting and ending line numbers, zero is the first line of the
1370visible pane and negative numbers are lines in the history.
1371.Ql -
1372to
1373.Fl S
1374is the start of the history and to
1375.Fl E
1376the end of the visible pane.
1377The default is to capture only the visible contents of the pane.
1378.It Xo
1379.Ic choose-client
1380.Op Fl NZ
1381.Op Fl F Ar format
1382.Op Fl f Ar filter
1383.Op Fl O Ar sort-order
1384.Op Fl t Ar target-pane
1385.Op Ar template
1386.Xc
1387Put a pane into client mode, allowing a client to be selected interactively from
1388a list.
1389.Fl Z
1390zooms the pane.
1391The following keys may be used in client mode:
1392.Bl -column "Key" "Function" -offset indent
1393.It Sy "Key" Ta Sy "Function"
1394.It Li "Enter" Ta "Choose selected client"
1395.It Li "Up" Ta "Select previous client"
1396.It Li "Down" Ta "Select next client"
1397.It Li "C-s" Ta "Search by name"
1398.It Li "n" Ta "Repeat last search"
1399.It Li "t" Ta "Toggle if client is tagged"
1400.It Li "T" Ta "Tag no clients"
1401.It Li "C-t" Ta "Tag all clients"
1402.It Li "d" Ta "Detach selected client"
1403.It Li "D" Ta "Detach tagged clients"
1404.It Li "x" Ta "Detach and HUP selected client"
1405.It Li "X" Ta "Detach and HUP tagged clients"
1406.It Li "z" Ta "Suspend selected client"
1407.It Li "Z" Ta "Suspend tagged clients"
1408.It Li "f" Ta "Enter a format to filter items"
1409.It Li "O" Ta "Change sort order"
1410.It Li "v" Ta "Toggle preview"
1411.It Li "q" Ta "Exit mode"
1412.El
1413.Pp
1414After a client is chosen,
1415.Ql %%
1416is replaced by the client name in
1417.Ar template
1418and the result executed as a command.
1419If
1420.Ar template
1421is not given, "detach-client -t '%%'" is used.
1422.Pp
1423.Fl O
1424specifies the initial sort order: one of
1425.Ql name ,
1426.Ql size ,
1427.Ql creation ,
1428or
1429.Ql activity .
1430.Fl f
1431specifies an initial filter: the filter is a format - if it evaluates to zero,
1432the item in the list is not shown, otherwise it is shown.
1433If a filter would lead to an empty list, it is ignored.
1434.Fl F
1435specifies the format for each item in the list.
1436.Fl N
1437starts without the preview.
1438This command works only if at least one client is attached.
1439.It Xo
1440.Ic choose-tree
1441.Op Fl GNswZ
1442.Op Fl F Ar format
1443.Op Fl f Ar filter
1444.Op Fl O Ar sort-order
1445.Op Fl t Ar target-pane
1446.Op Ar template
1447.Xc
1448Put a pane into tree mode, where a session, window or pane may be chosen
1449interactively from a list.
1450.Fl s
1451starts with sessions collapsed and
1452.Fl w
1453with windows collapsed.
1454.Fl Z
1455zooms the pane.
1456The following keys may be used in tree mode:
1457.Bl -column "Key" "Function" -offset indent
1458.It Sy "Key" Ta Sy "Function"
1459.It Li "Enter" Ta "Choose selected item"
1460.It Li "Up" Ta "Select previous item"
1461.It Li "Down" Ta "Select next item"
1462.It Li "x" Ta "Kill selected item"
1463.It Li "X" Ta "Kill tagged items"
1464.It Li "<" Ta "Scroll list of previews left"
1465.It Li ">" Ta "Scroll list of previews right"
1466.It Li "C-s" Ta "Search by name"
1467.It Li "n" Ta "Repeat last search"
1468.It Li "t" Ta "Toggle if item is tagged"
1469.It Li "T" Ta "Tag no items"
1470.It Li "C-t" Ta "Tag all items"
1471.It Li "\&:" Ta "Run a command for each tagged item"
1472.It Li "f" Ta "Enter a format to filter items"
1473.It Li "O" Ta "Change sort order"
1474.It Li "v" Ta "Toggle preview"
1475.It Li "q" Ta "Exit mode"
1476.El
1477.Pp
1478After a session, window or pane is chosen,
1479.Ql %%
1480is replaced by the target in
1481.Ar template
1482and the result executed as a command.
1483If
1484.Ar template
1485is not given, "switch-client -t '%%'" is used.
1486.Pp
1487.Fl O
1488specifies the initial sort order: one of
1489.Ql index ,
1490.Ql name ,
1491or
1492.Ql time .
1493.Fl f
1494specifies an initial filter: the filter is a format - if it evaluates to zero,
1495the item in the list is not shown, otherwise it is shown.
1496If a filter would lead to an empty list, it is ignored.
1497.Fl F
1498specifies the format for each item in the tree.
1499.Fl N
1500starts without the preview.
1501.Fl G
1502includes all sessions in any session groups in the tree rather than only the
1503first.
1504This command works only if at least one client is attached.
1505.It Xo
1506.Ic display-panes
1507.Op Fl d Ar duration
1508.Op Fl t Ar target-client
1509.Op Ar template
1510.Xc
1511.D1 (alias: Ic displayp )
1512Display a visible indicator of each pane shown by
1513.Ar target-client .
1514See the
1515.Ic display-panes-colour
1516and
1517.Ic display-panes-active-colour
1518session options.
1519The indicator is closed when a key is pressed or
1520.Ar duration
1521milliseconds have passed.
1522If
1523.Fl d
1524is not given,
1525.Ic display-panes-time
1526is used.
1527A duration of zero means the indicator stays until a key is pressed.
1528While the indicator is on screen, a pane may be chosen with the
1529.Ql 0
1530to
1531.Ql 9
1532keys, which will cause
1533.Ar template
1534to be executed as a command with
1535.Ql %%
1536substituted by the pane ID.
1537The default
1538.Ar template
1539is "select-pane -t '%%'".
1540.It Xo Ic find-window
1541.Op Fl CNT
1542.Op Fl t Ar target-pane
1543.Ar match-string
1544.Xc
1545.D1 (alias: Ic findw )
1546Search for the
1547.Xr fnmatch 3
1548pattern
1549.Ar match-string
1550in window names, titles, and visible content (but not history).
1551The flags control matching behavior:
1552.Fl C
1553matches only visible window contents,
1554.Fl N
1555matches only the window name and
1556.Fl T
1557matches only the window title.
1558The default is
1559.Fl CNT .
1560.Pp
1561This command works only if at least one client is attached.
1562.It Xo Ic join-pane
1563.Op Fl bdhv
1564.Oo Fl l
1565.Ar size |
1566.Fl p Ar percentage Oc
1567.Op Fl s Ar src-pane
1568.Op Fl t Ar dst-pane
1569.Xc
1570.D1 (alias: Ic joinp )
1571Like
1572.Ic split-window ,
1573but instead of splitting
1574.Ar dst-pane
1575and creating a new pane, split it and move
1576.Ar src-pane
1577into the space.
1578This can be used to reverse
1579.Ic break-pane .
1580The
1581.Fl b
1582option causes
1583.Ar src-pane
1584to be joined to left of or above
1585.Ar dst-pane .
1586.Pp
1587If
1588.Fl s
1589is omitted and a marked pane is present (see
1590.Ic select-pane
1591.Fl m ) ,
1592the marked pane is used rather than the current pane.
1593.It Xo Ic kill-pane
1594.Op Fl a
1595.Op Fl t Ar target-pane
1596.Xc
1597.D1 (alias: Ic killp )
1598Destroy the given pane.
1599If no panes remain in the containing window, it is also destroyed.
1600The
1601.Fl a
1602option kills all but the pane given with
1603.Fl t .
1604.It Xo Ic kill-window
1605.Op Fl a
1606.Op Fl t Ar target-window
1607.Xc
1608.D1 (alias: Ic killw )
1609Kill the current window or the window at
1610.Ar target-window ,
1611removing it from any sessions to which it is linked.
1612The
1613.Fl a
1614option kills all but the window given with
1615.Fl t .
1616.It Xo Ic last-pane
1617.Op Fl de
1618.Op Fl t Ar target-window
1619.Xc
1620.D1 (alias: Ic lastp )
1621Select the last (previously selected) pane.
1622.Fl e
1623enables or
1624.Fl d
1625disables input to the pane.
1626.It Ic last-window Op Fl t Ar target-session
1627.D1 (alias: Ic last )
1628Select the last (previously selected) window.
1629If no
1630.Ar target-session
1631is specified, select the last window of the current session.
1632.It Xo Ic link-window
1633.Op Fl adk
1634.Op Fl s Ar src-window
1635.Op Fl t Ar dst-window
1636.Xc
1637.D1 (alias: Ic linkw )
1638Link the window at
1639.Ar src-window
1640to the specified
1641.Ar dst-window .
1642If
1643.Ar dst-window
1644is specified and no such window exists, the
1645.Ar src-window
1646is linked there.
1647With
1648.Fl a ,
1649the window is moved to the next index up (following windows
1650are moved if necessary).
1651If
1652.Fl k
1653is given and
1654.Ar dst-window
1655exists, it is killed, otherwise an error is generated.
1656If
1657.Fl d
1658is given, the newly linked window is not selected.
1659.It Xo Ic list-panes
1660.Op Fl as
1661.Op Fl F Ar format
1662.Op Fl t Ar target
1663.Xc
1664.D1 (alias: Ic lsp )
1665If
1666.Fl a
1667is given,
1668.Ar target
1669is ignored and all panes on the server are listed.
1670If
1671.Fl s
1672is given,
1673.Ar target
1674is a session (or the current session).
1675If neither is given,
1676.Ar target
1677is a window (or the current window).
1678For the meaning of the
1679.Fl F
1680flag, see the
1681.Sx FORMATS
1682section.
1683.It Xo Ic list-windows
1684.Op Fl a
1685.Op Fl F Ar format
1686.Op Fl t Ar target-session
1687.Xc
1688.D1 (alias: Ic lsw )
1689If
1690.Fl a
1691is given, list all windows on the server.
1692Otherwise, list windows in the current session or in
1693.Ar target-session .
1694For the meaning of the
1695.Fl F
1696flag, see the
1697.Sx FORMATS
1698section.
1699.It Xo Ic move-pane
1700.Op Fl bdhv
1701.Oo Fl l
1702.Ar size |
1703.Fl p Ar percentage Oc
1704.Op Fl s Ar src-pane
1705.Op Fl t Ar dst-pane
1706.Xc
1707.D1 (alias: Ic movep )
1708Like
1709.Ic join-pane ,
1710but
1711.Ar src-pane
1712and
1713.Ar dst-pane
1714may belong to the same window.
1715.It Xo Ic move-window
1716.Op Fl ardk
1717.Op Fl s Ar src-window
1718.Op Fl t Ar dst-window
1719.Xc
1720.D1 (alias: Ic movew )
1721This is similar to
1722.Ic link-window ,
1723except the window at
1724.Ar src-window
1725is moved to
1726.Ar dst-window .
1727With
1728.Fl r ,
1729all windows in the session are renumbered in sequential order, respecting
1730the
1731.Ic base-index
1732option.
1733.It Xo Ic new-window
1734.Op Fl adkP
1735.Op Fl c Ar start-directory
1736.Op Fl F Ar format
1737.Op Fl n Ar window-name
1738.Op Fl t Ar target-window
1739.Op Ar shell-command
1740.Xc
1741.D1 (alias: Ic neww )
1742Create a new window.
1743With
1744.Fl a ,
1745the new window is inserted at the next index up from the specified
1746.Ar target-window ,
1747moving windows up if necessary,
1748otherwise
1749.Ar target-window
1750is the new window location.
1751.Pp
1752If
1753.Fl d
1754is given, the session does not make the new window the current window.
1755.Ar target-window
1756represents the window to be created; if the target already exists an error is
1757shown, unless the
1758.Fl k
1759flag is used, in which case it is destroyed.
1760.Ar shell-command
1761is the command to execute.
1762If
1763.Ar shell-command
1764is not specified, the value of the
1765.Ic default-command
1766option is used.
1767.Fl c
1768specifies the working directory in which the new window is created.
1769.Pp
1770When the shell command completes, the window closes.
1771See the
1772.Ic remain-on-exit
1773option to change this behaviour.
1774.Pp
1775The
1776.Ev TERM
1777environment variable must be set to
1778.Ql screen
1779or
1780.Ql tmux
1781for all programs running
1782.Em inside
1783.Nm .
1784New windows will automatically have
1785.Ql TERM=screen
1786added to their environment, but care must be taken not to reset this in shell
1787start-up files.
1788.Pp
1789The
1790.Fl P
1791option prints information about the new window after it has been created.
1792By default, it uses the format
1793.Ql #{session_name}:#{window_index}
1794but a different format may be specified with
1795.Fl F .
1796.It Ic next-layout Op Fl t Ar target-window
1797.D1 (alias: Ic nextl )
1798Move a window to the next layout and rearrange the panes to fit.
1799.It Xo Ic next-window
1800.Op Fl a
1801.Op Fl t Ar target-session
1802.Xc
1803.D1 (alias: Ic next )
1804Move to the next window in the session.
1805If
1806.Fl a
1807is used, move to the next window with an alert.
1808.It Xo Ic pipe-pane
1809.Op Fl IOo
1810.Op Fl t Ar target-pane
1811.Op Ar shell-command
1812.Xc
1813.D1 (alias: Ic pipep )
1814Pipe output sent by the program in
1815.Ar target-pane
1816to a shell command or vice versa.
1817A pane may only be connected to one command at a time, any existing pipe is
1818closed before
1819.Ar shell-command
1820is executed.
1821The
1822.Ar shell-command
1823string may contain the special character sequences supported by the
1824.Ic status-left
1825option.
1826If no
1827.Ar shell-command
1828is given, the current pipe (if any) is closed.
1829.Pp
1830.Fl I
1831and
1832.Fl O
1833specify which of the
1834.Ar shell-command
1835output streams are connected to the pane:
1836with
1837.Fl I
1838stdout is connected (so anything
1839.Ar shell-command
1840prints is written to the pane as if it were typed);
1841with
1842.Fl O
1843stdin is connected (so any output in the pane is piped to
1844.Ar shell-command ) .
1845Both may be used together and if neither are specified,
1846.Fl O
1847is used.
1848.Pp
1849The
1850.Fl o
1851option only opens a new pipe if no previous pipe exists, allowing a pipe to
1852be toggled with a single key, for example:
1853.Bd -literal -offset indent
1854bind-key C-p pipe-pane -o 'cat >>~/output.#I-#P'
1855.Ed
1856.It Xo Ic previous-layout
1857.Op Fl t Ar target-window
1858.Xc
1859.D1 (alias: Ic prevl )
1860Move to the previous layout in the session.
1861.It Xo Ic previous-window
1862.Op Fl a
1863.Op Fl t Ar target-session
1864.Xc
1865.D1 (alias: Ic prev )
1866Move to the previous window in the session.
1867With
1868.Fl a ,
1869move to the previous window with an alert.
1870.It Xo Ic rename-window
1871.Op Fl t Ar target-window
1872.Ar new-name
1873.Xc
1874.D1 (alias: Ic renamew )
1875Rename the current window, or the window at
1876.Ar target-window
1877if specified, to
1878.Ar new-name .
1879.It Xo Ic resize-pane
1880.Op Fl DLMRUZ
1881.Op Fl t Ar target-pane
1882.Op Fl x Ar width
1883.Op Fl y Ar height
1884.Op Ar adjustment
1885.Xc
1886.D1 (alias: Ic resizep )
1887Resize a pane, up, down, left or right by
1888.Ar adjustment
1889with
1890.Fl U ,
1891.Fl D ,
1892.Fl L
1893or
1894.Fl R ,
1895or
1896to an absolute size
1897with
1898.Fl x
1899or
1900.Fl y .
1901The
1902.Ar adjustment
1903is given in lines or cells (the default is 1).
1904.Pp
1905With
1906.Fl Z ,
1907the active pane is toggled between zoomed (occupying the whole of the window)
1908and unzoomed (its normal position in the layout).
1909.Pp
1910.Fl M
1911begins mouse resizing (only valid if bound to a mouse key binding, see
1912.Sx MOUSE SUPPORT ) .
1913.It Xo Ic respawn-pane
1914.Op Fl c Ar start-directory
1915.Op Fl k
1916.Op Fl t Ar target-pane
1917.Op Ar shell-command
1918.Xc
1919.D1 (alias: Ic respawnp )
1920Reactivate a pane in which the command has exited (see the
1921.Ic remain-on-exit
1922window option).
1923If
1924.Ar shell-command
1925is not given, the command used when the pane was created is executed.
1926The pane must be already inactive, unless
1927.Fl k
1928is given, in which case any existing command is killed.
1929.Fl c
1930specifies a new working directory for the pane.
1931.It Xo Ic respawn-window
1932.Op Fl c Ar start-directory
1933.Op Fl k
1934.Op Fl t Ar target-window
1935.Op Ar shell-command
1936.Xc
1937.D1 (alias: Ic respawnw )
1938Reactivate a window in which the command has exited (see the
1939.Ic remain-on-exit
1940window option).
1941If
1942.Ar shell-command
1943is not given, the command used when the window was created is executed.
1944The window must be already inactive, unless
1945.Fl k
1946is given, in which case any existing command is killed.
1947.Fl c
1948specifies a new working directory for the window.
1949.It Xo Ic rotate-window
1950.Op Fl DU
1951.Op Fl t Ar target-window
1952.Xc
1953.D1 (alias: Ic rotatew )
1954Rotate the positions of the panes within a window, either upward (numerically
1955lower) with
1956.Fl U
1957or downward (numerically higher).
1958.It Xo Ic select-layout
1959.Op Fl Enop
1960.Op Fl t Ar target-pane
1961.Op Ar layout-name
1962.Xc
1963.D1 (alias: Ic selectl )
1964Choose a specific layout for a window.
1965If
1966.Ar layout-name
1967is not given, the last preset layout used (if any) is reapplied.
1968.Fl n
1969and
1970.Fl p
1971are equivalent to the
1972.Ic next-layout
1973and
1974.Ic previous-layout
1975commands.
1976.Fl o
1977applies the last set layout if possible (undoes the most recent layout change).
1978.Fl E
1979spreads the current pane and any panes next to it out evenly.
1980.It Xo Ic select-pane
1981.Op Fl DdegLlMmRU
1982.Op Fl P Ar style
1983.Op Fl T Ar title
1984.Op Fl t Ar target-pane
1985.Xc
1986.D1 (alias: Ic selectp )
1987Make pane
1988.Ar target-pane
1989the active pane in window
1990.Ar target-window ,
1991or set its style (with
1992.Fl P ) .
1993If one of
1994.Fl D ,
1995.Fl L ,
1996.Fl R ,
1997or
1998.Fl U
1999is used, respectively the pane below, to the left, to the right, or above the
2000target pane is used.
2001.Fl l
2002is the same as using the
2003.Ic last-pane
2004command.
2005.Fl e
2006enables or
2007.Fl d
2008disables input to the pane.
2009.Pp
2010.Fl m
2011and
2012.Fl M
2013are used to set and clear the
2014.Em marked pane .
2015There is one marked pane at a time, setting a new marked pane clears the last.
2016The marked pane is the default target for
2017.Fl s
2018to
2019.Ic join-pane ,
2020.Ic swap-pane
2021and
2022.Ic swap-window .
2023.Pp
2024Each pane has a style: by default the
2025.Ic window-style
2026and
2027.Ic window-active-style
2028options are used,
2029.Ic select-pane
2030.Fl P
2031sets the style for a single pane.
2032For example, to set the pane 1 background to red:
2033.Bd -literal -offset indent
2034select-pane -t:.1 -P 'bg=red'
2035.Ed
2036.Pp
2037.Fl g
2038shows the current pane style.
2039.Pp
2040.Fl T
2041sets the pane title.
2042.It Xo Ic select-window
2043.Op Fl lnpT
2044.Op Fl t Ar target-window
2045.Xc
2046.D1 (alias: Ic selectw )
2047Select the window at
2048.Ar target-window .
2049.Fl l ,
2050.Fl n
2051and
2052.Fl p
2053are equivalent to the
2054.Ic last-window ,
2055.Ic next-window
2056and
2057.Ic previous-window
2058commands.
2059If
2060.Fl T
2061is given and the selected window is already the current window,
2062the command behaves like
2063.Ic last-window .
2064.It Xo Ic split-window
2065.Op Fl bdfhvP
2066.Op Fl c Ar start-directory
2067.Oo Fl l
2068.Ar size |
2069.Fl p Ar percentage Oc
2070.Op Fl t Ar target-pane
2071.Op Ar shell-command
2072.Op Fl F Ar format
2073.Xc
2074.D1 (alias: Ic splitw )
2075Create a new pane by splitting
2076.Ar target-pane :
2077.Fl h
2078does a horizontal split and
2079.Fl v
2080a vertical split; if neither is specified,
2081.Fl v
2082is assumed.
2083The
2084.Fl l
2085and
2086.Fl p
2087options specify the size of the new pane in lines (for vertical split) or in
2088cells (for horizontal split), or as a percentage, respectively.
2089The
2090.Fl b
2091option causes the new pane to be created to the left of or above
2092.Ar target-pane .
2093The
2094.Fl f
2095option creates a new pane spanning the full window height (with
2096.Fl h )
2097or full window width (with
2098.Fl v ) ,
2099instead of splitting the active pane.
2100All other options have the same meaning as for the
2101.Ic new-window
2102command.
2103.It Xo Ic swap-pane
2104.Op Fl dDU
2105.Op Fl s Ar src-pane
2106.Op Fl t Ar dst-pane
2107.Xc
2108.D1 (alias: Ic swapp )
2109Swap two panes.
2110If
2111.Fl U
2112is used and no source pane is specified with
2113.Fl s ,
2114.Ar dst-pane
2115is swapped with the previous pane (before it numerically);
2116.Fl D
2117swaps with the next pane (after it numerically).
2118.Fl d
2119instructs
2120.Nm
2121not to change the active pane.
2122.Pp
2123If
2124.Fl s
2125is omitted and a marked pane is present (see
2126.Ic select-pane
2127.Fl m ) ,
2128the marked pane is used rather than the current pane.
2129.It Xo Ic swap-window
2130.Op Fl d
2131.Op Fl s Ar src-window
2132.Op Fl t Ar dst-window
2133.Xc
2134.D1 (alias: Ic swapw )
2135This is similar to
2136.Ic link-window ,
2137except the source and destination windows are swapped.
2138It is an error if no window exists at
2139.Ar src-window .
2140.Pp
2141Like
2142.Ic swap-pane ,
2143if
2144.Fl s
2145is omitted and a marked pane is present (see
2146.Ic select-pane
2147.Fl m ) ,
2148the window containing the marked pane is used rather than the current window.
2149.It Xo Ic unlink-window
2150.Op Fl k
2151.Op Fl t Ar target-window
2152.Xc
2153.D1 (alias: Ic unlinkw )
2154Unlink
2155.Ar target-window .
2156Unless
2157.Fl k
2158is given, a window may be unlinked only if it is linked to multiple sessions -
2159windows may not be linked to no sessions;
2160if
2161.Fl k
2162is specified and the window is linked to only one session, it is unlinked and
2163destroyed.
2164.El
2165.Sh KEY BINDINGS
2166.Nm
2167allows a command to be bound to most keys, with or without a prefix key.
2168When specifying keys, most represent themselves (for example
2169.Ql A
2170to
2171.Ql Z ) .
2172Ctrl keys may be prefixed with
2173.Ql C-
2174or
2175.Ql ^ ,
2176and Alt (meta) with
2177.Ql M- .
2178In addition, the following special key names are accepted:
2179.Em Up ,
2180.Em Down ,
2181.Em Left ,
2182.Em Right ,
2183.Em BSpace ,
2184.Em BTab ,
2185.Em DC
2186(Delete),
2187.Em End ,
2188.Em Enter ,
2189.Em Escape ,
2190.Em F1
2191to
2192.Em F12 ,
2193.Em Home ,
2194.Em IC
2195(Insert),
2196.Em NPage/PageDown/PgDn ,
2197.Em PPage/PageUp/PgUp ,
2198.Em Space ,
2199and
2200.Em Tab .
2201Note that to bind the
2202.Ql \&"
2203or
2204.Ql '
2205keys, quotation marks are necessary, for example:
2206.Bd -literal -offset indent
2207bind-key '"' split-window
2208bind-key "'" new-window
2209.Ed
2210.Pp
2211Commands related to key bindings are as follows:
2212.Bl -tag -width Ds
2213.It Xo Ic bind-key
2214.Op Fl nr
2215.Op Fl T Ar key-table
2216.Ar key Ar command Op Ar arguments
2217.Xc
2218.D1 (alias: Ic bind )
2219Bind key
2220.Ar key
2221to
2222.Ar command .
2223Keys are bound in a key table.
2224By default (without -T), the key is bound in
2225the
2226.Em prefix
2227key table.
2228This table is used for keys pressed after the prefix key (for example,
2229by default
2230.Ql c
2231is bound to
2232.Ic new-window
2233in the
2234.Em prefix
2235table, so
2236.Ql C-b c
2237creates a new window).
2238The
2239.Em root
2240table is used for keys pressed without the prefix key: binding
2241.Ql c
2242to
2243.Ic new-window
2244in the
2245.Em root
2246table (not recommended) means a plain
2247.Ql c
2248will create a new window.
2249.Fl n
2250is an alias
2251for
2252.Fl T Ar root .
2253Keys may also be bound in custom key tables and the
2254.Ic switch-client
2255.Fl T
2256command used to switch to them from a key binding.
2257The
2258.Fl r
2259flag indicates this key may repeat, see the
2260.Ic repeat-time
2261option.
2262.Pp
2263To view the default bindings and possible commands, see the
2264.Ic list-keys
2265command.
2266.It Xo Ic list-keys
2267.Op Fl T Ar key-table
2268.Xc
2269.D1 (alias: Ic lsk )
2270List all key bindings.
2271Without
2272.Fl T
2273all key tables are printed.
2274With
2275.Fl T
2276only
2277.Ar key-table .
2278.It Xo Ic send-keys
2279.Op Fl lMRX
2280.Op Fl N Ar repeat-count
2281.Op Fl t Ar target-pane
2282.Ar key Ar ...
2283.Xc
2284.D1 (alias: Ic send )
2285Send a key or keys to a window.
2286Each argument
2287.Ar key
2288is the name of the key (such as
2289.Ql C-a
2290or
2291.Ql NPage )
2292to send; if the string is not recognised as a key, it is sent as a series of
2293characters.
2294The
2295.Fl l
2296flag disables key name lookup and sends the keys literally.
2297All arguments are sent sequentially from first to last.
2298The
2299.Fl R
2300flag causes the terminal state to be reset.
2301.Pp
2302.Fl M
2303passes through a mouse event (only valid if bound to a mouse key binding, see
2304.Sx MOUSE SUPPORT ) .
2305.Pp
2306.Fl X
2307is used to send a command into copy mode - see
2308the
2309.Sx WINDOWS AND PANES
2310section.
2311.Fl N
2312specifies a repeat count.
2313.It Xo Ic send-prefix
2314.Op Fl 2
2315.Op Fl t Ar target-pane
2316.Xc
2317Send the prefix key, or with
2318.Fl 2
2319the secondary prefix key, to a window as if it was pressed.
2320.It Xo Ic unbind-key
2321.Op Fl an
2322.Op Fl T Ar key-table
2323.Ar key
2324.Xc
2325.D1 (alias: Ic unbind )
2326Unbind the command bound to
2327.Ar key .
2328.Fl n
2329and
2330.Fl T
2331are the same as for
2332.Ic bind-key .
2333If
2334.Fl a
2335is present, all key bindings are removed.
2336.El
2337.Sh OPTIONS
2338The appearance and behaviour of
2339.Nm
2340may be modified by changing the value of various options.
2341There are three types of option:
2342.Em server options ,
2343.Em session options
2344and
2345.Em window options .
2346.Pp
2347The
2348.Nm
2349server has a set of global options which do not apply to any particular
2350window or session.
2351These are altered with the
2352.Ic set-option
2353.Fl s
2354command, or displayed with the
2355.Ic show-options
2356.Fl s
2357command.
2358.Pp
2359In addition, each individual session may have a set of session options, and
2360there is a separate set of global session options.
2361Sessions which do not have a particular option configured inherit the value
2362from the global session options.
2363Session options are set or unset with the
2364.Ic set-option
2365command and may be listed with the
2366.Ic show-options
2367command.
2368The available server and session options are listed under the
2369.Ic set-option
2370command.
2371.Pp
2372Similarly, a set of window options is attached to each window, and there is
2373a set of global window options from which any unset options are inherited.
2374Window options are altered with the
2375.Ic set-window-option
2376command and can be listed with the
2377.Ic show-window-options
2378command.
2379All window options are documented with the
2380.Ic set-window-option
2381command.
2382.Pp
2383.Nm
2384also supports user options which are prefixed with a
2385.Ql \&@ .
2386User options may have any name, so long as they are prefixed with
2387.Ql \&@ ,
2388and be set to any string.
2389For example:
2390.Bd -literal -offset indent
2391$ tmux setw -q @foo "abc123"
2392$ tmux showw -v @foo
2393abc123
2394.Ed
2395.Pp
2396Commands which set options are as follows:
2397.Bl -tag -width Ds
2398.It Xo Ic set-option
2399.Op Fl aFgoqsuw
2400.Op Fl t Ar target-session | Ar target-window
2401.Ar option Ar value
2402.Xc
2403.D1 (alias: Ic set )
2404Set a window option with
2405.Fl w
2406(equivalent to the
2407.Ic set-window-option
2408command),
2409a server option with
2410.Fl s ,
2411otherwise a session option.
2412If
2413.Fl g
2414is given, the global session or window option is set.
2415.Fl F
2416expands formats in the option value.
2417The
2418.Fl u
2419flag unsets an option, so a session inherits the option from the global
2420options (or with
2421.Fl g ,
2422restores a global option to the default).
2423.Pp
2424The
2425.Fl o
2426flag prevents setting an option that is already set and the
2427.Fl q
2428flag suppresses errors about unknown or ambiguous options.
2429.Pp
2430With
2431.Fl a ,
2432and if the option expects a string or a style,
2433.Ar value
2434is appended to the existing setting.
2435For example:
2436.Bd -literal -offset indent
2437set -g status-left "foo"
2438set -ag status-left "bar"
2439.Ed
2440.Pp
2441Will result in
2442.Ql foobar .
2443And:
2444.Bd -literal -offset indent
2445set -g status-style "bg=red"
2446set -ag status-style "fg=blue"
2447.Ed
2448.Pp
2449Will result in a red background
2450.Em and
2451blue foreground.
2452Without
2453.Fl a ,
2454the result would be the default background and a blue foreground.
2455.Pp
2456Available window options are listed under
2457.Ic set-window-option .
2458.Pp
2459.Ar value
2460depends on the option and may be a number, a string, or a flag (on, off, or
2461omitted to toggle).
2462.Pp
2463Available server options are:
2464.Bl -tag -width Ds
2465.It Ic buffer-limit Ar number
2466Set the number of buffers; as new buffers are added to the top of the stack,
2467old ones are removed from the bottom if necessary to maintain this maximum
2468length.
2469.It Xo Ic command-alias[]
2470.Ar name=value
2471.Xc
2472This is an array of custom aliases for commands.
2473If an unknown command matches
2474.Ar name ,
2475it is replaced with
2476.Ar value .
2477For example, after:
2478.Pp
2479.Dl set -s command-alias[100] zoom='resize-pane -Z'
2480.Pp
2481Using:
2482.Pp
2483.Dl zoom -t:.1
2484.Pp
2485Is equivalent to:
2486.Pp
2487.Dl resize-pane -Z -t:.1
2488.Pp
2489Note that aliases are expanded when a command is parsed rather than when it is
2490executed, so binding an alias with
2491.Ic bind-key
2492will bind the expanded form.
2493.It Ic default-terminal Ar terminal
2494Set the default terminal for new windows created in this session - the
2495default value of the
2496.Ev TERM
2497environment variable.
2498For
2499.Nm
2500to work correctly, this
2501.Em must
2502be set to
2503.Ql screen ,
2504.Ql tmux
2505or a derivative of them.
2506.It Ic escape-time Ar time
2507Set the time in milliseconds for which
2508.Nm
2509waits after an escape is input to determine if it is part of a function or meta
2510key sequences.
2511The default is 500 milliseconds.
2512.It Xo Ic exit-empty
2513.Op Ic on | off
2514.Xc
2515If enabled (the default), the server will exit when there are no active
2516sessions.
2517.It Xo Ic exit-unattached
2518.Op Ic on | off
2519.Xc
2520If enabled, the server will exit when there are no attached clients.
2521.It Xo Ic focus-events
2522.Op Ic on | off
2523.Xc
2524When enabled, focus events are requested from the terminal if supported and
2525passed through to applications running in
2526.Nm .
2527Attached clients should be detached and attached again after changing this
2528option.
2529.It Ic history-file Ar path
2530If not empty, a file to which
2531.Nm
2532will write command prompt history on exit and load it from on start.
2533.It Ic message-limit Ar number
2534Set the number of error or information messages to save in the message log for
2535each client.
2536The default is 100.
2537.It Xo Ic set-clipboard
2538.Op Ic on | external | off
2539.Xc
2540Attempt to set the terminal clipboard content using the
2541.Xr xterm 1
2542escape sequence, if there is an
2543.Em \&Ms
2544entry in the
2545.Xr terminfo 5
2546description (see the
2547.Sx TERMINFO EXTENSIONS
2548section).
2549.Pp
2550If set to
2551.Ic on ,
2552.Nm
2553will both accept the escape sequence to create a buffer and attempt to set
2554the terminal clipboard.
2555If set to
2556.Ic external ,
2557.Nm
2558will attempt to set the terminal clipboard but ignore attempts
2559by applications to set
2560.Nm
2561buffers.
2562If
2563.Ic off ,
2564.Nm
2565will neither accept the clipboard escape sequence nor attempt to set the
2566clipboard.
2567.Pp
2568Note that this feature needs to be enabled in
2569.Xr xterm 1
2570by setting the resource:
2571.Bd -literal -offset indent
2572disallowedWindowOps: 20,21,SetXprop
2573.Ed
2574.Pp
2575Or changing this property from the
2576.Xr xterm 1
2577interactive menu when required.
2578.It Ic terminal-overrides[] Ar string
2579Allow terminal descriptions read using
2580.Xr terminfo 5
2581to be overridden.
2582Each entry is a colon-separated string made up of a terminal type pattern
2583(matched using
2584.Xr fnmatch 3 )
2585and a set of
2586.Em name=value
2587entries.
2588.Pp
2589For example, to set the
2590.Ql clear
2591.Xr terminfo 5
2592entry to
2593.Ql \ee[H\ee[2J
2594for all terminal types matching
2595.Ql rxvt* :
2596.Pp
2597.Dl "rxvt*:clear=\ee[H\ee[2J"
2598.Pp
2599The terminal entry value is passed through
2600.Xr strunvis 3
2601before interpretation.
2602.El
2603.Pp
2604Available session options are:
2605.Bl -tag -width Ds
2606.It Xo Ic activity-action
2607.Op Ic any | none | current | other
2608.Xc
2609Set action on window activity when
2610.Ic monitor-activity
2611is on.
2612.Ic any
2613means activity in any window linked to a session causes a bell or message
2614(depending on
2615.Ic visual-activity )
2616in the current window of that session,
2617.Ic none
2618means all activity is ignored (equivalent to
2619.Ic monitor-activity
2620being off),
2621.Ic current
2622means only activity in windows other than the current window are ignored and
2623.Ic other
2624means activity in the current window is ignored but not those in other windows.
2625.It Ic assume-paste-time Ar milliseconds
2626If keys are entered faster than one in
2627.Ar milliseconds ,
2628they are assumed to have been pasted rather than typed and
2629.Nm
2630key bindings are not processed.
2631The default is one millisecond and zero disables.
2632.It Ic base-index Ar index
2633Set the base index from which an unused index should be searched when a new
2634window is created.
2635The default is zero.
2636.It Xo Ic bell-action
2637.Op Ic any | none | current | other
2638.Xc
2639Set action on a bell in a window when
2640.Ic monitor-bell
2641is on.
2642The values are the same as those for
2643.Ic activity-action .
2644.It Ic default-command Ar shell-command
2645Set the command used for new windows (if not specified when the window is
2646created) to
2647.Ar shell-command ,
2648which may be any
2649.Xr sh 1
2650command.
2651The default is an empty string, which instructs
2652.Nm
2653to create a login shell using the value of the
2654.Ic default-shell
2655option.
2656.It Ic default-shell Ar path
2657Specify the default shell.
2658This is used as the login shell for new windows when the
2659.Ic default-command
2660option is set to empty, and must be the full path of the executable.
2661When started
2662.Nm
2663tries to set a default value from the first suitable of the
2664.Ev SHELL
2665environment variable, the shell returned by
2666.Xr getpwuid 3 ,
2667or
2668.Pa /bin/sh .
2669This option should be configured when
2670.Nm
2671is used as a login shell.
2672.It Xo Ic destroy-unattached
2673.Op Ic on | off
2674.Xc
2675If enabled and the session is no longer attached to any clients, it is
2676destroyed.
2677.It Xo Ic detach-on-destroy
2678.Op Ic on | off
2679.Xc
2680If on (the default), the client is detached when the session it is attached to
2681is destroyed.
2682If off, the client is switched to the most recently active of the remaining
2683sessions.
2684.It Ic display-panes-active-colour Ar colour
2685Set the colour used by the
2686.Ic display-panes
2687command to show the indicator for the active pane.
2688.It Ic display-panes-colour Ar colour
2689Set the colour used by the
2690.Ic display-panes
2691command to show the indicators for inactive panes.
2692.It Ic display-panes-time Ar time
2693Set the time in milliseconds for which the indicators shown by the
2694.Ic display-panes
2695command appear.
2696.It Ic display-time Ar time
2697Set the amount of time for which status line messages and other on-screen
2698indicators are displayed.
2699If set to 0, messages and indicators are displayed until a key is pressed.
2700.Ar time
2701is in milliseconds.
2702.It Ic history-limit Ar lines
2703Set the maximum number of lines held in window history.
2704This setting applies only to new windows - existing window histories are not
2705resized and retain the limit at the point they were created.
2706.It Ic key-table Ar key-table
2707Set the default key table to
2708.Ar key-table
2709instead of
2710.Em root .
2711.It Ic lock-after-time Ar number
2712Lock the session (like the
2713.Ic lock-session
2714command) after
2715.Ar number
2716seconds of inactivity.
2717The default is not to lock (set to 0).
2718.It Ic lock-command Ar shell-command
2719Command to run when locking each client.
2720The default is to run
2721.Xr lock 1
2722with
2723.Fl np .
2724.It Ic message-command-style Ar style
2725Set status line message command style, where
2726.Ar style
2727is a comma-separated list of characteristics to be specified.
2728.Pp
2729These may be
2730.Ql bg=colour
2731to set the background colour,
2732.Ql fg=colour
2733to set the foreground colour, and a list of attributes as specified below.
2734.Pp
2735The colour is one of:
2736.Ic black ,
2737.Ic red ,
2738.Ic green ,
2739.Ic yellow ,
2740.Ic blue ,
2741.Ic magenta ,
2742.Ic cyan ,
2743.Ic white ,
2744aixterm bright variants (if supported:
2745.Ic brightred ,
2746.Ic brightgreen ,
2747and so on),
2748.Ic colour0
2749to
2750.Ic colour255
2751from the 256-colour set,
2752.Ic default ,
2753or a hexadecimal RGB string such as
2754.Ql #ffffff ,
2755which chooses the closest match from the default 256-colour set.
2756.Pp
2757The attributes is either
2758.Ic none
2759or a comma-delimited list of one or more of:
2760.Ic bright
2761(or
2762.Ic bold ) ,
2763.Ic dim ,
2764.Ic underscore ,
2765.Ic blink ,
2766.Ic reverse ,
2767.Ic hidden ,
2768.Ic italics ,
2769or
2770.Ic strikethrough
2771to turn an attribute on, or an attribute prefixed with
2772.Ql no
2773to turn one off.
2774.Pp
2775Examples are:
2776.Bd -literal -offset indent
2777fg=yellow,bold,underscore,blink
2778bg=black,fg=default,noreverse
2779.Ed
2780.Pp
2781With the
2782.Fl a
2783flag to the
2784.Ic set-option
2785command the new style is added otherwise the existing style is replaced.
2786.It Ic message-style Ar style
2787Set status line message style.
2788For how to specify
2789.Ar style ,
2790see the
2791.Ic message-command-style
2792option.
2793.It Xo Ic mouse
2794.Op Ic on | off
2795.Xc
2796If on,
2797.Nm
2798captures the mouse and allows mouse events to be bound as key bindings.
2799See the
2800.Sx MOUSE SUPPORT
2801section for details.
2802.It Ic prefix Ar key
2803Set the key accepted as a prefix key.
2804In addition to the standard keys described under
2805.Sx KEY BINDINGS ,
2806.Ic prefix
2807can be set to the special key
2808.Ql None
2809to set no prefix.
2810.It Ic prefix2 Ar key
2811Set a secondary key accepted as a prefix key.
2812Like
2813.Ic prefix ,
2814.Ic prefix2
2815can be set to
2816.Ql None .
2817.It Xo Ic renumber-windows
2818.Op Ic on | off
2819.Xc
2820If on, when a window is closed in a session, automatically renumber the other
2821windows in numerical order.
2822This respects the
2823.Ic base-index
2824option if it has been set.
2825If off, do not renumber the windows.
2826.It Ic repeat-time Ar time
2827Allow multiple commands to be entered without pressing the prefix-key again
2828in the specified
2829.Ar time
2830milliseconds (the default is 500).
2831Whether a key repeats may be set when it is bound using the
2832.Fl r
2833flag to
2834.Ic bind-key .
2835Repeat is enabled for the default keys bound to the
2836.Ic resize-pane
2837command.
2838.It Xo Ic set-titles
2839.Op Ic on | off
2840.Xc
2841Attempt to set the client terminal title using the
2842.Em tsl
2843and
2844.Em fsl
2845.Xr terminfo 5
2846entries if they exist.
2847.Nm
2848automatically sets these to the \ee]0;...\e007 sequence if
2849the terminal appears to be
2850.Xr xterm 1 .
2851This option is off by default.
2852.It Ic set-titles-string Ar string
2853String used to set the window title if
2854.Ic set-titles
2855is on.
2856Formats are expanded, see the
2857.Sx FORMATS
2858section.
2859.It Xo Ic silence-action
2860.Op Ic any | none | current | other
2861.Xc
2862Set action on window silence when
2863.Ic monitor-silence
2864is on.
2865The values are the same as those for
2866.Ic activity-action .
2867.It Xo Ic status
2868.Op Ic on | off
2869.Xc
2870Show or hide the status line.
2871.It Ic status-interval Ar interval
2872Update the status line every
2873.Ar interval
2874seconds.
2875By default, updates will occur every 15 seconds.
2876A setting of zero disables redrawing at interval.
2877.It Xo Ic status-justify
2878.Op Ic left | centre | right
2879.Xc
2880Set the position of the window list component of the status line: left, centre
2881or right justified.
2882.It Xo Ic status-keys
2883.Op Ic vi | emacs
2884.Xc
2885Use vi or emacs-style
2886key bindings in the status line, for example at the command prompt.
2887The default is emacs, unless the
2888.Ev VISUAL
2889or
2890.Ev EDITOR
2891environment variables are set and contain the string
2892.Ql vi .
2893.It Ic status-left Ar string
2894Display
2895.Ar string
2896(by default the session name) to the left of the status line.
2897.Ar string
2898will be passed through
2899.Xr strftime 3
2900and formats (see
2901.Sx FORMATS )
2902will be expanded.
2903It may also contain the special character sequence #[] to change the colour
2904or attributes, for example
2905.Ql #[fg=red,bright]
2906to set a bright red foreground.
2907See the
2908.Ic message-command-style
2909option for a description of colours and attributes.
2910.Pp
2911For details on how the names and titles can be set see the
2912.Sx "NAMES AND TITLES"
2913section.
2914.Pp
2915Examples are:
2916.Bd -literal -offset indent
2917#(sysctl vm.loadavg)
2918#[fg=yellow,bold]#(apm -l)%%#[default] [#S]
2919.Ed
2920.Pp
2921The default is
2922.Ql "[#S] " .
2923.It Ic status-left-length Ar length
2924Set the maximum
2925.Ar length
2926of the left component of the status line.
2927The default is 10.
2928.It Ic status-left-style Ar style
2929Set the style of the left part of the status line.
2930For how to specify
2931.Ar style ,
2932see the
2933.Ic message-command-style
2934option.
2935.It Xo Ic status-position
2936.Op Ic top | bottom
2937.Xc
2938Set the position of the status line.
2939.It Ic status-right Ar string
2940Display
2941.Ar string
2942to the right of the status line.
2943By default, the current pane title in double quotes, the date and the time
2944are shown.
2945As with
2946.Ic status-left ,
2947.Ar string
2948will be passed to
2949.Xr strftime 3
2950and character pairs are replaced.
2951.It Ic status-right-length Ar length
2952Set the maximum
2953.Ar length
2954of the right component of the status line.
2955The default is 40.
2956.It Ic status-right-style Ar style
2957Set the style of the right part of the status line.
2958For how to specify
2959.Ar style ,
2960see the
2961.Ic message-command-style
2962option.
2963.It Ic status-style Ar style
2964Set status line style.
2965For how to specify
2966.Ar style ,
2967see the
2968.Ic message-command-style
2969option.
2970.It Ic update-environment[] Ar variable
2971Set list of environment variables to be copied into the session environment
2972when a new session is created or an existing session is attached.
2973Any variables that do not exist in the source environment are set to be
2974removed from the session environment (as if
2975.Fl r
2976was given to the
2977.Ic set-environment
2978command).
2979.It Ic user-keys[] Ar key
2980Set list of user-defined key escape sequences.
2981Each item is associated with a key named
2982.Ql User0 ,
2983.Ql User1 ,
2984and so on.
2985.Pp
2986For example:
2987.Bd -literal -offset indent
2988set -s user-keys[0] "\ee[5;30012~"
2989bind User0 resize-pane -L 3
2990.Ed
2991.It Xo Ic visual-activity
2992.Op Ic on | off | both
2993.Xc
2994If on, display a message instead of sending a bell when activity occurs in a
2995window for which the
2996.Ic monitor-activity
2997window option is enabled.
2998If set to both, a bell and a message are produced.
2999.It Xo Ic visual-bell
3000.Op Ic on | off | both
3001.Xc
3002If on, a message is shown on a bell in a window for which the
3003.Ic monitor-bell
3004window option is enabled instead of it being passed through to the
3005terminal (which normally makes a sound).
3006If set to both, a bell and a message are produced.
3007Also see the
3008.Ic bell-action
3009option.
3010.It Xo Ic visual-silence
3011.Op Ic on | off | both
3012.Xc
3013If
3014.Ic monitor-silence
3015is enabled, prints a message after the interval has expired on a given window
3016instead of sending a bell.
3017If set to both, a bell and a message are produced.
3018.It Ic word-separators Ar string
3019Sets the session's conception of what characters are considered word
3020separators, for the purposes of the next and previous word commands in
3021copy mode.
3022The default is
3023.Ql \ -_@ .
3024.El
3025.It Xo Ic set-window-option
3026.Op Fl aFgoqu
3027.Op Fl t Ar target-window
3028.Ar option Ar value
3029.Xc
3030.D1 (alias: Ic setw )
3031Set a window option.
3032The
3033.Fl a ,
3034.Fl F ,
3035.Fl g ,
3036.Fl o ,
3037.Fl q
3038and
3039.Fl u
3040flags work similarly to the
3041.Ic set-option
3042command.
3043.Pp
3044Supported window options are:
3045.Pp
3046.Bl -tag -width Ds -compact
3047.It Xo Ic aggressive-resize
3048.Op Ic on | off
3049.Xc
3050Aggressively resize the chosen window.
3051This means that
3052.Nm
3053will resize the window to the size of the smallest session for which it is the
3054current window, rather than the smallest session to which it is attached.
3055The window may resize when the current window is changed on another sessions;
3056this option is good for full-screen programs which support
3057.Dv SIGWINCH
3058and poor for interactive programs such as shells.
3059.Pp
3060.It Xo Ic allow-rename
3061.Op Ic on | off
3062.Xc
3063Allow programs to change the window name using a terminal escape
3064sequence (\eek...\ee\e\e).
3065The default is off.
3066.Pp
3067.It Xo Ic alternate-screen
3068.Op Ic on | off
3069.Xc
3070This option configures whether programs running inside
3071.Nm
3072may use the terminal alternate screen feature, which allows the
3073.Em smcup
3074and
3075.Em rmcup
3076.Xr terminfo 5
3077capabilities.
3078The alternate screen feature preserves the contents of the window when an
3079interactive application starts and restores it on exit, so that any output
3080visible before the application starts reappears unchanged after it exits.
3081The default is on.
3082.Pp
3083.It Xo Ic automatic-rename
3084.Op Ic on | off
3085.Xc
3086Control automatic window renaming.
3087When this setting is enabled,
3088.Nm
3089will rename the window automatically using the format specified by
3090.Ic automatic-rename-format .
3091This flag is automatically disabled for an individual window when a name
3092is specified at creation with
3093.Ic new-window
3094or
3095.Ic new-session ,
3096or later with
3097.Ic rename-window ,
3098or with a terminal escape sequence.
3099It may be switched off globally with:
3100.Bd -literal -offset indent
3101set-window-option -g automatic-rename off
3102.Ed
3103.Pp
3104.It Ic automatic-rename-format Ar format
3105The format (see
3106.Sx FORMATS )
3107used when the
3108.Ic automatic-rename
3109option is enabled.
3110.Pp
3111.It Ic clock-mode-colour Ar colour
3112Set clock colour.
3113.Pp
3114.It Xo Ic clock-mode-style
3115.Op Ic 12 | 24
3116.Xc
3117Set clock hour format.
3118.Pp
3119.It Ic force-height Ar height
3120.It Ic force-width Ar width
3121Prevent
3122.Nm
3123from resizing a window to greater than
3124.Ar width
3125or
3126.Ar height .
3127A value of zero restores the default unlimited setting.
3128.Pp
3129.It Ic main-pane-height Ar height
3130.It Ic main-pane-width Ar width
3131Set the width or height of the main (left or top) pane in the
3132.Ic main-horizontal
3133or
3134.Ic main-vertical
3135layouts.
3136.Pp
3137.It Xo Ic mode-keys
3138.Op Ic vi | emacs
3139.Xc
3140Use vi or emacs-style key bindings in copy mode.
3141The default is emacs, unless
3142.Ev VISUAL
3143or
3144.Ev EDITOR
3145contains
3146.Ql vi .
3147.Pp
3148.It Ic mode-style Ar style
3149Set window modes style.
3150For how to specify
3151.Ar style ,
3152see the
3153.Ic message-command-style
3154option.
3155.Pp
3156.It Xo Ic monitor-activity
3157.Op Ic on | off
3158.Xc
3159Monitor for activity in the window.
3160Windows with activity are highlighted in the status line.
3161.Pp
3162.It Xo Ic monitor-bell
3163.Op Ic on | off
3164.Xc
3165Monitor for a bell in the window.
3166Windows with a bell are highlighted in the status line.
3167.Pp
3168.It Xo Ic monitor-silence
3169.Op Ic interval
3170.Xc
3171Monitor for silence (no activity) in the window within
3172.Ic interval
3173seconds.
3174Windows that have been silent for the interval are highlighted in the
3175status line.
3176An interval of zero disables the monitoring.
3177.Pp
3178.It Ic other-pane-height Ar height
3179Set the height of the other panes (not the main pane) in the
3180.Ic main-horizontal
3181layout.
3182If this option is set to 0 (the default), it will have no effect.
3183If both the
3184.Ic main-pane-height
3185and
3186.Ic other-pane-height
3187options are set, the main pane will grow taller to make the other panes the
3188specified height, but will never shrink to do so.
3189.Pp
3190.It Ic other-pane-width Ar width
3191Like
3192.Ic other-pane-height ,
3193but set the width of other panes in the
3194.Ic main-vertical
3195layout.
3196.Pp
3197.It Ic pane-active-border-style Ar style
3198Set the pane border style for the currently active pane.
3199For how to specify
3200.Ar style ,
3201see the
3202.Ic message-command-style
3203option.
3204Attributes are ignored.
3205.Pp
3206.It Ic pane-base-index Ar index
3207Like
3208.Ic base-index ,
3209but set the starting index for pane numbers.
3210.Pp
3211.It Ic pane-border-format Ar format
3212Set the text shown in pane border status lines.
3213.Pp
3214.It Xo Ic pane-border-status
3215.Op Ic off | top | bottom
3216.Xc
3217Turn pane border status lines off or set their position.
3218.Pp
3219.It Ic pane-border-style Ar style
3220Set the pane border style for panes aside from the active pane.
3221For how to specify
3222.Ar style ,
3223see the
3224.Ic message-command-style
3225option.
3226Attributes are ignored.
3227.Pp
3228.It Xo Ic remain-on-exit
3229.Op Ic on | off
3230.Xc
3231A window with this flag set is not destroyed when the program running in it
3232exits.
3233The window may be reactivated with the
3234.Ic respawn-window
3235command.
3236.Pp
3237.It Xo Ic synchronize-panes
3238.Op Ic on | off
3239.Xc
3240Duplicate input to any pane to all other panes in the same window (only
3241for panes that are not in any special mode).
3242.Pp
3243.It Ic window-active-style Ar style
3244Set the style for the window's active pane.
3245For how to specify
3246.Ar style ,
3247see the
3248.Ic message-command-style
3249option.
3250.Pp
3251.It Ic window-status-activity-style Ar style
3252Set status line style for windows with an activity alert.
3253For how to specify
3254.Ar style ,
3255see the
3256.Ic message-command-style
3257option.
3258.Pp
3259.It Ic window-status-bell-style Ar style
3260Set status line style for windows with a bell alert.
3261For how to specify
3262.Ar style ,
3263see the
3264.Ic message-command-style
3265option.
3266.Pp
3267.It Ic window-status-current-format Ar string
3268Like
3269.Ar window-status-format ,
3270but is the format used when the window is the current window.
3271.Pp
3272.It Ic window-status-current-style Ar style
3273Set status line style for the currently active window.
3274For how to specify
3275.Ar style ,
3276see the
3277.Ic message-command-style
3278option.
3279.Pp
3280.It Ic window-status-format Ar string
3281Set the format in which the window is displayed in the status line window list.
3282See the
3283.Ar status-left
3284option for details of special character sequences available.
3285The default is
3286.Ql #I:#W#F .
3287.Pp
3288.It Ic window-status-last-style Ar style
3289Set status line style for the last active window.
3290For how to specify
3291.Ar style ,
3292see the
3293.Ic message-command-style
3294option.
3295.Pp
3296.It Ic window-status-separator Ar string
3297Sets the separator drawn between windows in the status line.
3298The default is a single space character.
3299.Pp
3300.It Ic window-status-style Ar style
3301Set status line style for a single window.
3302For how to specify
3303.Ar style ,
3304see the
3305.Ic message-command-style
3306option.
3307.Pp
3308.It Ic window-style Ar style
3309Set the default window style.
3310For how to specify
3311.Ar style ,
3312see the
3313.Ic message-command-style
3314option.
3315.Pp
3316.It Xo Ic wrap-search
3317.Op Ic on | off
3318.Xc
3319If this option is set, searches will wrap around the end of the pane contents.
3320The default is on.
3321.Pp
3322.It Xo Ic xterm-keys
3323.Op Ic on | off
3324.Xc
3325If this option is set,
3326.Nm
3327will generate
3328.Xr xterm 1 -style
3329function key sequences; these have a number included to indicate modifiers such
3330as Shift, Alt or Ctrl.
3331.El
3332.It Xo Ic show-options
3333.Op Fl gqsvw
3334.Op Fl t Ar target-session | Ar target-window
3335.Op Ar option
3336.Xc
3337.D1 (alias: Ic show )
3338Show the window options (or a single window option if given) with
3339.Fl w
3340(equivalent to
3341.Ic show-window-options ) ,
3342the server options with
3343.Fl s ,
3344otherwise the session options for
3345.Ar target session .
3346Global session or window options are listed if
3347.Fl g
3348is used.
3349.Fl v
3350shows only the option value, not the name.
3351If
3352.Fl q
3353is set, no error will be returned if
3354.Ar option
3355is unset.
3356.It Xo Ic show-window-options
3357.Op Fl gv
3358.Op Fl t Ar target-window
3359.Op Ar option
3360.Xc
3361.D1 (alias: Ic showw )
3362List the window options or a single option for
3363.Ar target-window ,
3364or the global window options if
3365.Fl g
3366is used.
3367.Fl v
3368shows only the option value, not the name.
3369.El
3370.Sh HOOKS
3371.Nm
3372allows commands to run on various triggers, called
3373.Em hooks .
3374Most
3375.Nm
3376commands have an
3377.Em after
3378hook and there are a number of hooks not associated with commands.
3379.Pp
3380A command's after
3381hook is run after it completes, except when the command is run as part of a hook
3382itself.
3383They are named with an
3384.Ql after-
3385prefix.
3386For example, the following command adds a hook to select the even-vertical
3387layout after every
3388.Ic split-window :
3389.Bd -literal -offset indent
3390set-hook after-split-window "selectl even-vertical"
3391.Ed
3392.Pp
3393All the notifications listed in the
3394.Sx CONTROL MODE
3395section are hooks (without any arguments), except
3396.Ic %exit .
3397The following additional hooks are available:
3398.Bl -tag -width "XXXXXXXXXXXXXXXXXXXXXX"
3399.It alert-activity
3400Run when a window has activity.
3401See
3402.Ic monitor-activity .
3403.It alert-bell
3404Run when a window has received a bell.
3405See
3406.Ic monitor-bell .
3407.It alert-silence
3408Run when a window has been silent.
3409See
3410.Ic monitor-silence .
3411.It client-attached
3412Run when a client is attached.
3413.It client-detached
3414Run when a client is detached
3415.It client-resized
3416Run when a client is resized.
3417.It client-session-changed
3418Run when a client's attached session is changed.
3419.It pane-died
3420Run when the program running in a pane exits, but
3421.Ic remain-on-exit
3422is on so the pane has not closed.
3423.It pane-exited
3424Run when the program running in a pane exits.
3425.It pane-set-clipboard
3426Run when the terminal clipboard is set using the
3427.Xr xterm 1
3428escape sequence.
3429.It session-created
3430Run when a new session created.
3431.It session-closed
3432Run when a session closed.
3433.It session-renamed
3434Run when a session is renamed.
3435.It window-linked
3436Run when a window is linked into a session.
3437.It window-renamed
3438Run when a window is renamed.
3439.It window-unlinked
3440Run when a window is unlinked from a session.
3441.El
3442.Pp
3443Hooks are managed with these commands:
3444.Bl -tag -width Ds
3445.It Xo Ic set-hook
3446.Op Fl gu
3447.Op Fl t Ar target-session
3448.Ar hook-name
3449.Ar command
3450.Xc
3451Sets (or with
3452.Fl u
3453unsets) hook
3454.Ar hook-name
3455to
3456.Ar command .
3457If
3458.Fl g
3459is given,
3460.Em hook-name
3461is added to the global list of hooks, otherwise it is added to the session
3462hooks (for
3463.Ar target-session
3464with
3465.Fl t ) .
3466Like options, session hooks inherit from the global ones.
3467.It Xo Ic show-hooks
3468.Op Fl g
3469.Op Fl t Ar target-session
3470.Xc
3471Shows the global list of hooks with
3472.Fl g ,
3473otherwise the session hooks.
3474.El
3475.Sh MOUSE SUPPORT
3476If the
3477.Ic mouse
3478option is on (the default is off),
3479.Nm
3480allows mouse events to be bound as keys.
3481The name of each key is made up of a mouse event (such as
3482.Ql MouseUp1 )
3483and a location suffix (one of
3484.Ql Pane
3485for the contents of a pane,
3486.Ql Border
3487for a pane border or
3488.Ql Status
3489for the status line).
3490The following mouse events are available:
3491.Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent
3492.It Li "WheelUp" Ta "WheelDown" Ta ""
3493.It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" Ta "MouseDragEnd1"
3494.It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" Ta "MouseDragEnd2"
3495.It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" Ta "MouseDragEnd3"
3496.It Li "DoubleClick1" Ta "DoubleClick2" Ta "DoubleClick3"
3497.It Li "TripleClick1" Ta "TripleClick2" Ta "TripleClick3"
3498.El
3499.Pp
3500Each should be suffixed with a location, for example
3501.Ql MouseDown1Status .
3502.Pp
3503The special token
3504.Ql {mouse}
3505or
3506.Ql =
3507may be used as
3508.Ar target-window
3509or
3510.Ar target-pane
3511in commands bound to mouse key bindings.
3512It resolves to the window or pane over which the mouse event took place
3513(for example, the window in the status line over which button 1 was released for a
3514.Ql MouseUp1Status
3515binding, or the pane over which the wheel was scrolled for a
3516.Ql WheelDownPane
3517binding).
3518.Pp
3519The
3520.Ic send-keys
3521.Fl M
3522flag may be used to forward a mouse event to a pane.
3523.Pp
3524The default key bindings allow the mouse to be used to select and resize panes,
3525to copy text and to change window using the status line.
3526These take effect if the
3527.Ic mouse
3528option is turned on.
3529.Sh FORMATS
3530Certain commands accept the
3531.Fl F
3532flag with a
3533.Ar format
3534argument.
3535This is a string which controls the output format of the command.
3536Replacement variables are enclosed in
3537.Ql #{
3538and
3539.Ql } ,
3540for example
3541.Ql #{session_name} .
3542The possible variables are listed in the table below, or the name of a
3543.Nm
3544option may be used for an option's value.
3545Some variables have a shorter alias such as
3546.Ql #S ,
3547and
3548.Ql ##
3549is replaced by a single
3550.Ql # .
3551.Pp
3552Conditionals are available by prefixing with
3553.Ql \&?
3554and separating two alternatives with a comma;
3555if the specified variable exists and is not zero, the first alternative
3556is chosen, otherwise the second is used.
3557For example
3558.Ql #{?session_attached,attached,not attached}
3559will include the string
3560.Ql attached
3561if the session is attached and the string
3562.Ql not attached
3563if it is unattached, or
3564.Ql #{?automatic-rename,yes,no}
3565will include
3566.Ql yes
3567if
3568.Ic automatic-rename
3569is enabled, or
3570.Ql no
3571if not.
3572.Pp
3573Comparisons may be expressed by prefixing two comma-separated
3574alternatives by
3575.Ql ==
3576or
3577.Ql !=
3578and a colon.
3579For example
3580.Ql #{==:#{host},myhost}
3581will be replaced by
3582.Ql 1
3583if running on
3584.Ql myhost ,
3585otherwise by
3586.Ql 0 .
3587An
3588.Ql m
3589specifies an
3590.Xr fnmatch 3
3591comparison where the first argument is the pattern and the second the string to
3592compare, for example
3593.Ql #{m:*foo*,#{host}} .
3594.Ql ||
3595and
3596.Ql &&
3597evaluate to true if either or both of two comma-separated alternatives are
3598true, for example
3599.Ql #{||,#{pane_in_mode},#{alternate_on}} .
3600A
3601.Ql C
3602performs a search for an
3603.Xr fnmatch 3
3604pattern in the pane content and evaluates to zero if not found, or a line
3605number if found.
3606.Pp
3607A limit may be placed on the length of the resultant string by prefixing it
3608by an
3609.Ql = ,
3610a number and a colon.
3611Positive numbers count from the start of the string and negative from the end,
3612so
3613.Ql #{=5:pane_title}
3614will include at most the first 5 characters of the pane title, or
3615.Ql #{=-5:pane_title}
3616the last 5 characters.
3617Prefixing a time variable with
3618.Ql t:
3619will convert it to a string, so if
3620.Ql #{window_activity}
3621gives
3622.Ql 1445765102 ,
3623.Ql #{t:window_activity}
3624gives
3625.Ql Sun Oct 25 09:25:02 2015 .
3626The
3627.Ql b:
3628and
3629.Ql d:
3630prefixes are
3631.Xr basename 3
3632and
3633.Xr dirname 3
3634of the variable respectively.
3635A prefix of the form
3636.Ql s/foo/bar/:
3637will substitute
3638.Ql foo
3639with
3640.Ql bar
3641throughout.
3642.Pp
3643In addition, the first line of a shell command's output may be inserted using
3644.Ql #() .
3645For example,
3646.Ql #(uptime)
3647will insert the system's uptime.
3648When constructing formats,
3649.Nm
3650does not wait for
3651.Ql #()
3652commands to finish; instead, the previous result from running the same command is used,
3653or a placeholder if the command has not been run before.
3654If the command hasn't exited, the most recent line of output will be used, but the status
3655line will not be updated more than once a second.
3656Commands are executed with the
3657.Nm
3658global environment set (see the
3659.Sx ENVIRONMENT
3660section).
3661.Pp
3662The following variables are available, where appropriate:
3663.Bl -column "XXXXXXXXXXXXXXXXXXX" "XXXXX"
3664.It Sy "Variable name" Ta Sy "Alias" Ta Sy "Replaced with"
3665.It Li "alternate_on" Ta "" Ta "If pane is in alternate screen"
3666.It Li "alternate_saved_x" Ta "" Ta "Saved cursor X in alternate screen"
3667.It Li "alternate_saved_y" Ta "" Ta "Saved cursor Y in alternate screen"
3668.It Li "buffer_created" Ta "" Ta "Time buffer created"
3669.It Li "buffer_name" Ta "" Ta "Name of buffer"
3670.It Li "buffer_sample" Ta "" Ta "Sample of start of buffer"
3671.It Li "buffer_size" Ta "" Ta "Size of the specified buffer in bytes"
3672.It Li "client_activity" Ta "" Ta "Time client last had activity"
3673.It Li "client_created" Ta "" Ta "Time client created"
3674.It Li "client_control_mode" Ta "" Ta "1 if client is in control mode"
3675.It Li "client_discarded" Ta "" Ta "Bytes discarded when client behind"
3676.It Li "client_height" Ta "" Ta "Height of client"
3677.It Li "client_key_table" Ta "" Ta "Current key table"
3678.It Li "client_last_session" Ta "" Ta "Name of the client's last session"
3679.It Li "client_name" Ta "" Ta "Name of client"
3680.It Li "client_pid" Ta "" Ta "PID of client process"
3681.It Li "client_prefix" Ta "" Ta "1 if prefix key has been pressed"
3682.It Li "client_readonly" Ta "" Ta "1 if client is readonly"
3683.It Li "client_session" Ta "" Ta "Name of the client's session"
3684.It Li "client_termname" Ta "" Ta "Terminal name of client"
3685.It Li "client_termtype" Ta "" Ta "Terminal type of client"
3686.It Li "client_tty" Ta "" Ta "Pseudo terminal of client"
3687.It Li "client_utf8" Ta "" Ta "1 if client supports utf8"
3688.It Li "client_width" Ta "" Ta "Width of client"
3689.It Li "client_written" Ta "" Ta "Bytes written to client"
3690.It Li "command" Ta "" Ta "Name of command in use, if any"
3691.It Li "command_list_name" Ta "" Ta "Command name if listing commands"
3692.It Li "command_list_alias" Ta "" Ta "Command alias if listing commands"
3693.It Li "command_list_usage" Ta "" Ta "Command usage if listing commands"
3694.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
3695.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"
3696.It Li "cursor_y" Ta "" Ta "Cursor Y position in pane"
3697.It Li "history_bytes" Ta "" Ta "Number of bytes in window history"
3698.It Li "history_limit" Ta "" Ta "Maximum window history lines"
3699.It Li "history_size" Ta "" Ta "Size of history in lines"
3700.It Li "hook" Ta "" Ta "Name of running hook, if any"
3701.It Li "hook_pane" Ta "" Ta "ID of pane where hook was run, if any"
3702.It Li "hook_session" Ta "" Ta "ID of session where hook was run, if any"
3703.It Li "hook_session_name" Ta "" Ta "Name of session where hook was run, if any"
3704.It Li "hook_window" Ta "" Ta "ID of window where hook was run, if any"
3705.It Li "hook_window_name" Ta "" Ta "Name of window where hook was run, if any"
3706.It Li "host" Ta "#H" Ta "Hostname of local host"
3707.It Li "host_short" Ta "#h" Ta "Hostname of local host (no domain name)"
3708.It Li "insert_flag" Ta "" Ta "Pane insert flag"
3709.It Li "keypad_cursor_flag" Ta "" Ta "Pane keypad cursor flag"
3710.It Li "keypad_flag" Ta "" Ta "Pane keypad flag"
3711.It Li "line" Ta "" Ta "Line number in the list"
3712.It Li "mouse_any_flag" Ta "" Ta "Pane mouse any flag"
3713.It Li "mouse_button_flag" Ta "" Ta "Pane mouse button flag"
3714.It Li "mouse_standard_flag" Ta "" Ta "Pane mouse standard flag"
3715.It Li "mouse_all_flag" Ta "" Ta "Pane mouse all flag"
3716.It Li "pane_active" Ta "" Ta "1 if active pane"
3717.It Li "pane_at_bottom" Ta "" Ta "1 if pane is at the bottom of window"
3718.It Li "pane_at_left" Ta "" Ta "1 if pane is at the left of window"
3719.It Li "pane_at_right" Ta "" Ta "1 if pane is at the right of window"
3720.It Li "pane_at_top" Ta "" Ta "1 if pane is at the top of window"
3721.It Li "pane_bottom" Ta "" Ta "Bottom of pane"
3722.It Li "pane_current_command" Ta "" Ta "Current command if available"
3723.It Li "pane_dead" Ta "" Ta "1 if pane is dead"
3724.It Li "pane_dead_status" Ta "" Ta "Exit status of process in dead pane"
3725.It Li "pane_format" Ta "" Ta "1 if format is for a pane (not assuming the current)"
3726.It Li "pane_height" Ta "" Ta "Height of pane"
3727.It Li "pane_id" Ta "#D" Ta "Unique pane ID"
3728.It Li "pane_in_mode" Ta "" Ta "If pane is in a mode"
3729.It Li "pane_input_off" Ta "" Ta "If input to pane is disabled"
3730.It Li "pane_index" Ta "#P" Ta "Index of pane"
3731.It Li "pane_left" Ta "" Ta "Left of pane"
3732.It Li "pane_mode" Ta "" Ta "Name of pane mode, if any."
3733.It Li "pane_pid" Ta "" Ta "PID of first process in pane"
3734.It Li "pane_pipe" Ta "" Ta "1 if pane is being piped"
3735.It Li "pane_right" Ta "" Ta "Right of pane"
3736.It Li "pane_search_string" Ta "" Ta "Last search string in copy mode"
3737.It Li "pane_start_command" Ta "" Ta "Command pane started with"
3738.It Li "pane_synchronized" Ta "" Ta "If pane is synchronized"
3739.It Li "pane_tabs" Ta "" Ta "Pane tab positions"
3740.It Li "pane_title" Ta "#T" Ta "Title of pane"
3741.It Li "pane_top" Ta "" Ta "Top of pane"
3742.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
3743.It Li "pane_width" Ta "" Ta "Width of pane"
3744.It Li "pid" Ta ""  Ta "Server PID"
3745.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
3746.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
3747.It Li "scroll_position" Ta "" Ta "Scroll position in copy mode"
3748.It Li "selection_present" Ta "" Ta "1 if selection started in copy mode"
3749.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts"
3750.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
3751.It Li "session_activity" Ta "" Ta "Time of session last activity"
3752.It Li "session_created" Ta "" Ta "Time session created"
3753.It Li "session_format" Ta "" Ta "1 if format is for a session (not assuming the current)"
3754.It Li "session_last_attached" Ta "" Ta "Time session last attached"
3755.It Li "session_group" Ta "" Ta "Name of session group"
3756.It Li "session_group_size" Ta "" Ta "Size of session group"
3757.It Li "session_group_list" Ta "" Ta "List of sessions in group"
3758.It Li "session_grouped" Ta "" Ta "1 if session in a group"
3759.It Li "session_height" Ta "" Ta "Height of session"
3760.It Li "session_id" Ta "" Ta "Unique session ID"
3761.It Li "session_many_attached" Ta "" Ta "1 if multiple clients attached"
3762.It Li "session_name" Ta "#S" Ta "Name of session"
3763.It Li "session_stack" Ta "" Ta "Window indexes in most recent order"
3764.It Li "session_width" Ta "" Ta "Width of session"
3765.It Li "session_windows" Ta "" Ta "Number of windows in session"
3766.It Li "socket_path" Ta "" Ta "Server socket path"
3767.It Li "start_time" Ta "" Ta "Server start time"
3768.It Li "window_activity" Ta "" Ta "Time of window last activity"
3769.It Li "window_activity_flag" Ta "" Ta "1 if window has activity"
3770.It Li "window_active" Ta "" Ta "1 if window active"
3771.It Li "window_bell_flag" Ta "" Ta "1 if window has bell"
3772.It Li "window_flags" Ta "#F" Ta "Window flags"
3773.It Li "window_format" Ta "" Ta "1 if format is for a window (not assuming the current)"
3774.It Li "window_height" Ta "" Ta "Height of window"
3775.It Li "window_id" Ta "" Ta "Unique window ID"
3776.It Li "window_index" Ta "#I" Ta "Index of window"
3777.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
3778.It Li "window_layout" Ta "" Ta "Window layout description, ignoring zoomed window panes"
3779.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
3780.It Li "window_name" Ta "#W" Ta "Name of window"
3781.It Li "window_panes" Ta "" Ta "Number of panes in window"
3782.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
3783.It Li "window_stack_index" Ta "" Ta "Index in session most recent stack"
3784.It Li "window_visible_layout" Ta "" Ta "Window layout description, respecting zoomed window panes"
3785.It Li "window_width" Ta "" Ta "Width of window"
3786.It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"
3787.It Li "wrap_flag" Ta "" Ta "Pane wrap flag"
3788.El
3789.Sh NAMES AND TITLES
3790.Nm
3791distinguishes between names and titles.
3792Windows and sessions have names, which may be used to specify them in targets
3793and are displayed in the status line and various lists: the name is the
3794.Nm
3795identifier for a window or session.
3796Only panes have titles.
3797A pane's title is typically set by the program running inside the pane using
3798an escape sequence (like it would set the
3799.Xr xterm 1
3800window title in
3801.Xr X 7 ) .
3802Windows themselves do not have titles - a window's title is the title of its
3803active pane.
3804.Nm
3805itself may set the title of the terminal in which the client is running, see
3806the
3807.Ic set-titles
3808option.
3809.Pp
3810A session's name is set with the
3811.Ic new-session
3812and
3813.Ic rename-session
3814commands.
3815A window's name is set with one of:
3816.Bl -enum -width Ds
3817.It
3818A command argument (such as
3819.Fl n
3820for
3821.Ic new-window
3822or
3823.Ic new-session ) .
3824.It
3825An escape sequence:
3826.Bd -literal -offset indent
3827$ printf '\e033kWINDOW_NAME\e033\e\e'
3828.Ed
3829.It
3830Automatic renaming, which sets the name to the active command in the window's
3831active pane.
3832See the
3833.Ic automatic-rename
3834option.
3835.El
3836.Pp
3837When a pane is first created, its title is the hostname.
3838A pane's title can be set via the OSC title setting sequence, for example:
3839.Bd -literal -offset indent
3840$ printf '\e033]2;My Title\e033\e\e'
3841.Ed
3842.Pp
3843It can also be modified with the
3844.Ic select-pane
3845.Fl T
3846command.
3847.Sh ENVIRONMENT
3848When the server is started,
3849.Nm
3850copies the environment into the
3851.Em global environment ;
3852in addition, each session has a
3853.Em session environment .
3854When a window is created, the session and global environments are merged.
3855If a variable exists in both, the value from the session environment is used.
3856The result is the initial environment passed to the new process.
3857.Pp
3858The
3859.Ic update-environment
3860session option may be used to update the session environment from the client
3861when a new session is created or an old reattached.
3862.Nm
3863also initialises the
3864.Ev TMUX
3865variable with some internal information to allow commands to be executed
3866from inside, and the
3867.Ev TERM
3868variable with the correct terminal setting of
3869.Ql screen .
3870.Pp
3871Commands to alter and view the environment are:
3872.Bl -tag -width Ds
3873.It Xo Ic set-environment
3874.Op Fl gru
3875.Op Fl t Ar target-session
3876.Ar name Op Ar value
3877.Xc
3878.D1 (alias: Ic setenv )
3879Set or unset an environment variable.
3880If
3881.Fl g
3882is used, the change is made in the global environment; otherwise, it is applied
3883to the session environment for
3884.Ar target-session .
3885The
3886.Fl u
3887flag unsets a variable.
3888.Fl r
3889indicates the variable is to be removed from the environment before starting a
3890new process.
3891.It Xo Ic show-environment
3892.Op Fl gs
3893.Op Fl t Ar target-session
3894.Op Ar variable
3895.Xc
3896.D1 (alias: Ic showenv )
3897Display the environment for
3898.Ar target-session
3899or the global environment with
3900.Fl g .
3901If
3902.Ar variable
3903is omitted, all variables are shown.
3904Variables removed from the environment are prefixed with
3905.Ql - .
3906If
3907.Fl s
3908is used, the output is formatted as a set of Bourne shell commands.
3909.El
3910.Sh STATUS LINE
3911.Nm
3912includes an optional status line which is displayed in the bottom line of each
3913terminal.
3914By default, the status line is enabled (it may be disabled with the
3915.Ic status
3916session option) and contains, from left-to-right: the name of the current
3917session in square brackets; the window list; the title of the active pane
3918in double quotes; and the time and date.
3919.Pp
3920The status line is made of three parts: configurable left and right sections
3921(which may contain dynamic content such as the time or output from a shell
3922command, see the
3923.Ic status-left ,
3924.Ic status-left-length ,
3925.Ic status-right ,
3926and
3927.Ic status-right-length
3928options below), and a central window list.
3929By default, the window list shows the index, name and (if any) flag of the
3930windows present in the current session in ascending numerical order.
3931It may be customised with the
3932.Ar window-status-format
3933and
3934.Ar window-status-current-format
3935options.
3936The flag is one of the following symbols appended to the window name:
3937.Bl -column "Symbol" "Meaning" -offset indent
3938.It Sy "Symbol" Ta Sy "Meaning"
3939.It Li "*" Ta "Denotes the current window."
3940.It Li "-" Ta "Marks the last window (previously selected)."
3941.It Li "#" Ta "Window activity is monitored and activity has been detected."
3942.It Li "\&!" Ta "Window bells are monitored and a bell has occurred in the window."
3943.It Li "~" Ta "The window has been silent for the monitor-silence interval."
3944.It Li "M" Ta "The window contains the marked pane."
3945.It Li "Z" Ta "The window's active pane is zoomed."
3946.El
3947.Pp
3948The # symbol relates to the
3949.Ic monitor-activity
3950window option.
3951The window name is printed in inverted colours if an alert (bell, activity or
3952silence) is present.
3953.Pp
3954The colour and attributes of the status line may be configured, the entire
3955status line using the
3956.Ic status-style
3957session option and individual windows using the
3958.Ic window-status-style
3959window option.
3960.Pp
3961The status line is automatically refreshed at interval if it has changed, the
3962interval may be controlled with the
3963.Ic status-interval
3964session option.
3965.Pp
3966Commands related to the status line are as follows:
3967.Bl -tag -width Ds
3968.It Xo Ic command-prompt
3969.Op Fl 1i
3970.Op Fl I Ar inputs
3971.Op Fl p Ar prompts
3972.Op Fl t Ar target-client
3973.Op Ar template
3974.Xc
3975Open the command prompt in a client.
3976This may be used from inside
3977.Nm
3978to execute commands interactively.
3979.Pp
3980If
3981.Ar template
3982is specified, it is used as the command.
3983If present,
3984.Fl I
3985is a comma-separated list of the initial text for each prompt.
3986If
3987.Fl p
3988is given,
3989.Ar prompts
3990is a comma-separated list of prompts which are displayed in order; otherwise
3991a single prompt is displayed, constructed from
3992.Ar template
3993if it is present, or
3994.Ql \&:
3995if not.
3996.Pp
3997Before the command is executed, the first occurrence of the string
3998.Ql %%
3999and all occurrences of
4000.Ql %1
4001are replaced by the response to the first prompt, all
4002.Ql %2
4003are replaced with the response to the second prompt, and so on for further
4004prompts.
4005Up to nine prompt responses may be replaced
4006.Po
4007.Ql %1
4008to
4009.Ql %9
4010.Pc .
4011.Ql %%%
4012is like
4013.Ql %%
4014but any quotation marks are escaped.
4015.Pp
4016.Fl 1
4017makes the prompt only accept one key press, in this case the resulting input
4018is a single character.
4019.Fl i
4020executes the command every time the prompt input changes instead of when the
4021user exits the command prompt.
4022.Pp
4023The following keys have a special meaning in the command prompt, depending
4024on the value of the
4025.Ic status-keys
4026option:
4027.Bl -column "FunctionXXXXXXXXXXXXXXXXXXXXXXXXX" "viXXXX" "emacsX" -offset indent
4028.It Sy "Function" Ta Sy "vi" Ta Sy "emacs"
4029.It Li "Cancel command prompt" Ta "Escape" Ta "Escape"
4030.It Li "Delete current word" Ta "" Ta "C-w"
4031.It Li "Delete entire command" Ta "d" Ta "C-u"
4032.It Li "Delete from cursor to end" Ta "D" Ta "C-k"
4033.It Li "Execute command" Ta "Enter" Ta "Enter"
4034.It Li "Get next command from history" Ta "" Ta "Down"
4035.It Li "Get previous command from history" Ta "" Ta "Up"
4036.It Li "Insert top paste buffer" Ta "p" Ta "C-y"
4037.It Li "Look for completions" Ta "Tab" Ta "Tab"
4038.It Li "Move cursor left" Ta "h" Ta "Left"
4039.It Li "Move cursor right" Ta "l" Ta "Right"
4040.It Li "Move cursor to end" Ta "$" Ta "C-e"
4041.It Li "Move cursor to next word" Ta "w" Ta "M-f"
4042.It Li "Move cursor to previous word" Ta "b" Ta "M-b"
4043.It Li "Move cursor to start" Ta "0" Ta "C-a"
4044.It Li "Transpose characters" Ta "" Ta "C-t"
4045.El
4046.It Xo Ic confirm-before
4047.Op Fl p Ar prompt
4048.Op Fl t Ar target-client
4049.Ar command
4050.Xc
4051.D1 (alias: Ic confirm )
4052Ask for confirmation before executing
4053.Ar command .
4054If
4055.Fl p
4056is given,
4057.Ar prompt
4058is the prompt to display; otherwise a prompt is constructed from
4059.Ar command .
4060It may contain the special character sequences supported by the
4061.Ic status-left
4062option.
4063.Pp
4064This command works only from inside
4065.Nm .
4066.It Xo Ic display-message
4067.Op Fl p
4068.Op Fl c Ar target-client
4069.Op Fl t Ar target-pane
4070.Op Ar message
4071.Xc
4072.D1 (alias: Ic display )
4073Display a message.
4074If
4075.Fl p
4076is given, the output is printed to stdout, otherwise it is displayed in the
4077.Ar target-client
4078status line.
4079The format of
4080.Ar message
4081is described in the
4082.Sx FORMATS
4083section; information is taken from
4084.Ar target-pane
4085if
4086.Fl t
4087is given, otherwise the active pane for the session attached to
4088.Ar target-client .
4089.El
4090.Sh BUFFERS
4091.Nm
4092maintains a set of named
4093.Em paste buffers .
4094Each buffer may be either explicitly or automatically named.
4095Explicitly named buffers are named when created with the
4096.Ic set-buffer
4097or
4098.Ic load-buffer
4099commands, or by renaming an automatically named buffer with
4100.Ic set-buffer
4101.Fl n .
4102Automatically named buffers are given a name such as
4103.Ql buffer0001 ,
4104.Ql buffer0002
4105and so on.
4106When the
4107.Ic buffer-limit
4108option is reached, the oldest automatically named buffer is deleted.
4109Explicitly named buffers are not subject to
4110.Ic buffer-limit
4111and may be deleted with
4112.Ic delete-buffer
4113command.
4114.Pp
4115Buffers may be added using
4116.Ic copy-mode
4117or the
4118.Ic set-buffer
4119and
4120.Ic load-buffer
4121commands, and pasted into a window using the
4122.Ic paste-buffer
4123command.
4124If a buffer command is used and no buffer is specified, the most
4125recently added automatically named buffer is assumed.
4126.Pp
4127A configurable history buffer is also maintained for each window.
4128By default, up to 2000 lines are kept; this can be altered with the
4129.Ic history-limit
4130option (see the
4131.Ic set-option
4132command above).
4133.Pp
4134The buffer commands are as follows:
4135.Bl -tag -width Ds
4136.It Xo
4137.Ic choose-buffer
4138.Op Fl NZ
4139.Op Fl F Ar format
4140.Op Fl f Ar filter
4141.Op Fl O Ar sort-order
4142.Op Fl t Ar target-pane
4143.Op Ar template
4144.Xc
4145Put a pane into buffer mode, where a buffer may be chosen interactively from
4146a list.
4147.Fl Z
4148zooms the pane.
4149The following keys may be used in buffer mode:
4150.Bl -column "Key" "Function" -offset indent
4151.It Sy "Key" Ta Sy "Function"
4152.It Li "Enter" Ta "Paste selected buffer"
4153.It Li "Up" Ta "Select previous buffer"
4154.It Li "Down" Ta "Select next buffer"
4155.It Li "C-s" Ta "Search by name or content"
4156.It Li "n" Ta "Repeat last search"
4157.It Li "t" Ta "Toggle if buffer is tagged"
4158.It Li "T" Ta "Tag no buffers"
4159.It Li "C-t" Ta "Tag all buffers"
4160.It Li "p" Ta "Paste selected buffer"
4161.It Li "P" Ta "Paste tagged buffers"
4162.It Li "d" Ta "Delete selected buffer"
4163.It Li "D" Ta "Delete tagged buffers"
4164.It Li "f" Ta "Enter a format to filter items"
4165.It Li "O" Ta "Change sort order"
4166.It Li "v" Ta "Toggle preview"
4167.It Li "q" Ta "Exit mode"
4168.El
4169.Pp
4170After a buffer is chosen,
4171.Ql %%
4172is replaced by the buffer name in
4173.Ar template
4174and the result executed as a command.
4175If
4176.Ar template
4177is not given, "paste-buffer -b '%%'" is used.
4178.Pp
4179.Fl O
4180specifies the initial sort order: one of
4181.Ql time ,
4182.Ql name
4183or
4184.Ql size .
4185.Fl f
4186specifies an initial filter: the filter is a format - if it evaluates to zero,
4187the item in the list is not shown, otherwise it is shown.
4188If a filter would lead to an empty list, it is ignored.
4189.Fl F
4190specifies the format for each item in the list.
4191.Fl N
4192starts without the preview.
4193This command works only if at least one client is attached.
4194.It Ic clear-history Op Fl t Ar target-pane
4195.D1 (alias: Ic clearhist )
4196Remove and free the history for the specified pane.
4197.It Ic delete-buffer Op Fl b Ar buffer-name
4198.D1 (alias: Ic deleteb )
4199Delete the buffer named
4200.Ar buffer-name ,
4201or the most recently added automatically named buffer if not specified.
4202.It Xo Ic list-buffers
4203.Op Fl F Ar format
4204.Xc
4205.D1 (alias: Ic lsb )
4206List the global buffers.
4207For the meaning of the
4208.Fl F
4209flag, see the
4210.Sx FORMATS
4211section.
4212.It Xo Ic load-buffer
4213.Op Fl b Ar buffer-name
4214.Ar path
4215.Xc
4216.D1 (alias: Ic loadb )
4217Load the contents of the specified paste buffer from
4218.Ar path .
4219.It Xo Ic paste-buffer
4220.Op Fl dpr
4221.Op Fl b Ar buffer-name
4222.Op Fl s Ar separator
4223.Op Fl t Ar target-pane
4224.Xc
4225.D1 (alias: Ic pasteb )
4226Insert the contents of a paste buffer into the specified pane.
4227If not specified, paste into the current one.
4228With
4229.Fl d ,
4230also delete the paste buffer.
4231When output, any linefeed (LF) characters in the paste buffer are replaced with
4232a separator, by default carriage return (CR).
4233A custom separator may be specified using the
4234.Fl s
4235flag.
4236The
4237.Fl r
4238flag means to do no replacement (equivalent to a separator of LF).
4239If
4240.Fl p
4241is specified, paste bracket control codes are inserted around the
4242buffer if the application has requested bracketed paste mode.
4243.It Xo Ic save-buffer
4244.Op Fl a
4245.Op Fl b Ar buffer-name
4246.Ar path
4247.Xc
4248.D1 (alias: Ic saveb )
4249Save the contents of the specified paste buffer to
4250.Ar path .
4251The
4252.Fl a
4253option appends to rather than overwriting the file.
4254.It Xo Ic set-buffer
4255.Op Fl a
4256.Op Fl b Ar buffer-name
4257.Op Fl n Ar new-buffer-name
4258.Ar data
4259.Xc
4260.D1 (alias: Ic setb )
4261Set the contents of the specified buffer to
4262.Ar data .
4263The
4264.Fl a
4265option appends to rather than overwriting the buffer.
4266The
4267.Fl n
4268option renames the buffer to
4269.Ar new-buffer-name .
4270.It Xo Ic show-buffer
4271.Op Fl b Ar buffer-name
4272.Xc
4273.D1 (alias: Ic showb )
4274Display the contents of the specified buffer.
4275.El
4276.Sh MISCELLANEOUS
4277Miscellaneous commands are as follows:
4278.Bl -tag -width Ds
4279.It Ic clock-mode Op Fl t Ar target-pane
4280Display a large clock.
4281.It Xo Ic if-shell
4282.Op Fl bF
4283.Op Fl t Ar target-pane
4284.Ar shell-command command
4285.Op Ar command
4286.Xc
4287.D1 (alias: Ic if )
4288Execute the first
4289.Ar command
4290if
4291.Ar shell-command
4292returns success or the second
4293.Ar command
4294otherwise.
4295Before being executed,
4296.Ar shell-command
4297is expanded using the rules specified in the
4298.Sx FORMATS
4299section, including those relevant to
4300.Ar target-pane .
4301With
4302.Fl b ,
4303.Ar shell-command
4304is run in the background.
4305.Pp
4306If
4307.Fl F
4308is given,
4309.Ar shell-command
4310is not executed but considered success if neither empty nor zero (after formats
4311are expanded).
4312.It Ic lock-server
4313.D1 (alias: Ic lock )
4314Lock each client individually by running the command specified by the
4315.Ic lock-command
4316option.
4317.It Xo Ic run-shell
4318.Op Fl b
4319.Op Fl t Ar target-pane
4320.Ar shell-command
4321.Xc
4322.D1 (alias: Ic run )
4323Execute
4324.Ar shell-command
4325in the background without creating a window.
4326Before being executed, shell-command is expanded using the rules specified in
4327the
4328.Sx FORMATS
4329section.
4330With
4331.Fl b ,
4332the command is run in the background.
4333After it finishes, any output to stdout is displayed in copy mode (in the pane
4334specified by
4335.Fl t
4336or the current pane if omitted).
4337If the command doesn't return success, the exit status is also displayed.
4338.It Xo Ic wait-for
4339.Op Fl L | S | U
4340.Ar channel
4341.Xc
4342.D1 (alias: Ic wait )
4343When used without options, prevents the client from exiting until woken using
4344.Ic wait-for
4345.Fl S
4346with the same channel.
4347When
4348.Fl L
4349is used, the channel is locked and any clients that try to lock the same
4350channel are made to wait until the channel is unlocked with
4351.Ic wait-for
4352.Fl U .
4353This command only works from outside
4354.Nm .
4355.El
4356.Sh TERMINFO EXTENSIONS
4357.Nm
4358understands some unofficial extensions to
4359.Xr terminfo 5 :
4360.Bl -tag -width Ds
4361.It Em Cs , Cr
4362Set the cursor colour.
4363The first takes a single string argument and is used to set the colour;
4364the second takes no arguments and restores the default cursor colour.
4365If set, a sequence such as this may be used
4366to change the cursor colour from inside
4367.Nm :
4368.Bd -literal -offset indent
4369$ printf '\e033]12;red\e033\e\e'
4370.Ed
4371.It Em \&Ss , Se
4372Set or reset the cursor style.
4373If set, a sequence such as this may be used
4374to change the cursor to an underline:
4375.Bd -literal -offset indent
4376$ printf '\e033[4 q'
4377.Ed
4378.Pp
4379If
4380.Em Se
4381is not set, \&Ss with argument 0 will be used to reset the cursor style instead.
4382.It Em \&Tc
4383Indicate that the terminal supports the
4384.Ql direct colour
4385RGB escape sequence (for example, \ee[38;2;255;255;255m).
4386.Pp
4387If supported, this is used for the OSC initialize colour escape sequence (which
4388may be enabled by adding the
4389.Ql initc
4390and
4391.Ql ccc
4392capabilities to the
4393.Nm
4394.Xr terminfo 5
4395entry).
4396.It Em \&Ms
4397Store the current buffer in the host terminal's selection (clipboard).
4398See the
4399.Em set-clipboard
4400option above and the
4401.Xr xterm 1
4402man page.
4403.El
4404.Sh CONTROL MODE
4405.Nm
4406offers a textual interface called
4407.Em control mode .
4408This allows applications to communicate with
4409.Nm
4410using a simple text-only protocol.
4411.Pp
4412In control mode, a client sends
4413.Nm
4414commands or command sequences terminated by newlines on standard input.
4415Each command will produce one block of output on standard output.
4416An output block consists of a
4417.Em %begin
4418line followed by the output (which may be empty).
4419The output block ends with a
4420.Em %end
4421or
4422.Em %error .
4423.Em %begin
4424and matching
4425.Em %end
4426or
4427.Em %error
4428have two arguments: an integer time (as seconds from epoch) and command number.
4429For example:
4430.Bd -literal -offset indent
4431%begin 1363006971 2
44320: ksh* (1 panes) [80x24] [layout b25f,80x24,0,0,2] @2 (active)
4433%end 1363006971 2
4434.Ed
4435.Pp
4436The
4437.Ic refresh-client
4438.Fl C
4439command may be used to set the size of a client in control mode.
4440.Pp
4441In control mode,
4442.Nm
4443outputs notifications.
4444A notification will never occur inside an output block.
4445.Pp
4446The following notifications are defined:
4447.Bl -tag -width Ds
4448.It Ic %client-session-changed Ar client Ar session-id Ar name
4449The client is now attached to the session with ID
4450.Ar session-id ,
4451which is named
4452.Ar name .
4453.It Ic %exit Op Ar reason
4454The
4455.Nm
4456client is exiting immediately, either because it is not attached to any session
4457or an error occurred.
4458If present,
4459.Ar reason
4460describes why the client exited.
4461.It Ic %layout-change Ar window-id Ar window-layout Ar window-visible-layout Ar window-flags
4462The layout of a window with ID
4463.Ar window-id
4464changed.
4465The new layout is
4466.Ar window-layout .
4467The window's visible layout is
4468.Ar window-visible-layout
4469and the window flags are
4470.Ar window-flags .
4471.It Ic %output Ar pane-id Ar value
4472A window pane produced output.
4473.Ar value
4474escapes non-printable characters and backslash as octal \\xxx.
4475.It Ic %pane-mode-changed Ar pane-id
4476The pane with ID
4477.Ar pane-id
4478has changed mode.
4479.It Ic %session-changed Ar session-id Ar name
4480The client is now attached to the session with ID
4481.Ar session-id ,
4482which is named
4483.Ar name .
4484.It Ic %session-renamed Ar name
4485The current session was renamed to
4486.Ar name .
4487.It Ic %session-window-changed Ar session-id Ar window-id
4488The session with ID
4489.Ar session-id
4490changed its active window to the window with ID
4491.Ar window-id .
4492.It Ic %sessions-changed
4493A session was created or destroyed.
4494.It Ic %unlinked-window-add Ar window-id
4495The window with ID
4496.Ar window-id
4497was created but is not linked to the current session.
4498.It Ic %window-add Ar window-id
4499The window with ID
4500.Ar window-id
4501was linked to the current session.
4502.It Ic %window-close Ar window-id
4503The window with ID
4504.Ar window-id
4505closed.
4506.It Ic %window-pane-changed Ar window-id Ar pane-id
4507The active pane in the window with ID
4508.Ar window-id
4509changed to the pane with ID
4510.Ar pane-id .
4511.It Ic %window-renamed Ar window-id Ar name
4512The window with ID
4513.Ar window-id
4514was renamed to
4515.Ar name .
4516.El
4517.Sh FILES
4518.Bl -tag -width "/etc/tmux.confXXX" -compact
4519.It Pa ~/.tmux.conf
4520Default
4521.Nm
4522configuration file.
4523.It Pa /etc/tmux.conf
4524System-wide configuration file.
4525.El
4526.Sh EXAMPLES
4527To create a new
4528.Nm
4529session running
4530.Xr vi 1 :
4531.Pp
4532.Dl $ tmux new-session vi
4533.Pp
4534Most commands have a shorter form, known as an alias.
4535For new-session, this is
4536.Ic new :
4537.Pp
4538.Dl $ tmux new vi
4539.Pp
4540Alternatively, the shortest unambiguous form of a command is accepted.
4541If there are several options, they are listed:
4542.Bd -literal -offset indent
4543$ tmux n
4544ambiguous command: n, could be: new-session, new-window, next-window
4545.Ed
4546.Pp
4547Within an active session, a new window may be created by typing
4548.Ql C-b c
4549(Ctrl
4550followed by the
4551.Ql b
4552key
4553followed by the
4554.Ql c
4555key).
4556.Pp
4557Windows may be navigated with:
4558.Ql C-b 0
4559(to select window 0),
4560.Ql C-b 1
4561(to select window 1), and so on;
4562.Ql C-b n
4563to select the next window; and
4564.Ql C-b p
4565to select the previous window.
4566.Pp
4567A session may be detached using
4568.Ql C-b d
4569(or by an external event such as
4570.Xr ssh 1
4571disconnection) and reattached with:
4572.Pp
4573.Dl $ tmux attach-session
4574.Pp
4575Typing
4576.Ql C-b \&?
4577lists the current key bindings in the current window; up and down may be used
4578to navigate the list or
4579.Ql q
4580to exit from it.
4581.Pp
4582Commands to be run when the
4583.Nm
4584server is started may be placed in the
4585.Pa ~/.tmux.conf
4586configuration file.
4587Common examples include:
4588.Pp
4589Changing the default prefix key:
4590.Bd -literal -offset indent
4591set-option -g prefix C-a
4592unbind-key C-b
4593bind-key C-a send-prefix
4594.Ed
4595.Pp
4596Turning the status line off, or changing its colour:
4597.Bd -literal -offset indent
4598set-option -g status off
4599set-option -g status-style bg=blue
4600.Ed
4601.Pp
4602Setting other options, such as the default command,
4603or locking after 30 minutes of inactivity:
4604.Bd -literal -offset indent
4605set-option -g default-command "exec /bin/ksh"
4606set-option -g lock-after-time 1800
4607.Ed
4608.Pp
4609Creating new key bindings:
4610.Bd -literal -offset indent
4611bind-key b set-option status
4612bind-key / command-prompt "split-window 'exec man %%'"
4613bind-key S command-prompt "new-window -n %1 'ssh %1'"
4614.Ed
4615.Sh SEE ALSO
4616.Xr pty 4
4617.Sh AUTHORS
4618.An Nicholas Marriott Aq Mt nicholas.marriott@gmail.com
4619