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