TMUX(1)
๐ TMUX(1) ๐
okay bestie, sit down, hydrate, because we're about to talk about the General Commands Manual entry for tmux โ the terminal multiplexer โ and she is iconic. ๐
โจ NAME โจ
tmux โ terminal multiplexer. that's it. that's the whole name. she's mysterious, she's powerful, she's the main character.
๐ธ SYNOPSIS ๐ธ
tmux [-2CDhlNuVv] [-c shell-command] [-f file] [-L socket-name]
[-S socket-path] [-T features] [command [flags]]
๐ฆ DESCRIPTION ๐ฆ
so like. tmux is a terminal multiplexer. what that means (fr fr) is she lets you create, access, and control a whole bunch of terminals from one single screen. it's giving "one screen, infinite windows" energy. ๐
and the way that she can be detached from a screen and just keep running in the background, minding her own business, and then later you reattach to her like nothing ever happened?? obsessed. โจ
when tmux starts up, she creates a new session with a single window and puts it on your screen. at the bottom of the screen there's a status line showing info about the current session, and that's also where you go to type in interactive commands. ๐
okay so definitions, because the terminology matters:
- A session is one single collection of pseudo terminals that
tmuxis managing. every session has one or more windows linked to it. - A window takes up the entire screen and may be split into rectangular panes, and each pane is its own separate pseudo terminal. (if you want the technical nitty-gritty on pseudo terminals, the
pty(4)manual page has you covered ๐ง) - Any number of
tmuxinstances may connect to the same session, and any number of windows may live in the same session. no cap. - Once all sessions are killed,
tmuxexits. periodt.
each session is persistent โ she will survive an accidental disconnection (think your ssh(1) connection timing out ๐ญ) or an intentional detach (that's the โC-b dโ key strokes, iykyk). and you can reattach to her with:
$ tmux attach
in tmux, a session gets displayed on screen by a client, and all the sessions are managed by a single server. the server and each client are separate processes, and they talk to each other through a socket in /tmp. ๐
the options are as follows:
-2โ forcetmuxto assume the terminal supports 256 colours. this is equivalent to-T 256. bestie, it's the same thing. ๐-Cโ start in control mode (peep the โCONTROL MODEโ section). give it twice (-CC) and it disables echo.-c shell-commandโ executeshell-commandusing the default shell. if it's necessary, thetmuxserver will get started so it can retrieve thedefault-shelloption. this one exists for compatibility withsh(1)whentmuxis used as a login shell.-Dโ do not start thetmuxserver as a daemon. this also turns theexit-emptyoption off. heads up: with-D,commandmay not be specified. โ ๏ธ-f fileโ specify an alternative configuration file. by default,tmuxloads the system configuration file from/etc/tmux.confif it's present, and then looks for a user configuration file at~/.tmux.confor$XDG_CONFIG_HOME/tmux/tmux.conf.
the configuration file is just a set of tmux commands that get executed in sequence when the server is first started. tmux loads configuration files once, when the server process has started. if you wanna load a file later, the source-file command is right there. ๐ซถ
tmux shows any error messages from commands in configuration files in the first session created, and then just keeps on processing the rest of the configuration file. she doesn't stop for anybody.
-hโ print usage information and exit.-L socket-nameโtmuxstores the server socket in a directory underTMUX_TMPDIR, or/tmpif that's unset. the default socket is nameddefault. this option lets you specify a different socket name, which means you can run several independenttmuxservers. unlike-S, a full path is not necessary: the sockets all get created in a directorytmux-UIDunder the directory given byTMUX_TMPDIR, or in/tmp. thetmux-UIDdirectory is created bytmuxand must not be world readable, writable or executable. ๐
if the socket is accidentally removed, you can send the SIGUSR1 signal to the tmux server process to recreate it (note that this will fail if any parent directories are missing).
-lโ behave as a login shell. ngl this flag currently has no effect and is only there for compatibility with other shells when usingtmuxas a login shell. ๐-Nโ do not start the server even if the command would normally do so (for examplenew-sessionorstart-server).-S socket-pathโ specify a full alternative path to the server socket. if-Sis specified, the default socket directory is not used and any-Lflag is ignored. ๐-T featuresโ set terminal features for the client. this is a comma-separated list of features. see theterminal-featuresoption.-uโ write UTF-8 output to the terminal even if the first environment variable ofLC_ALL,LC_CTYPE, orLANGthat is set does not contain"UTF-8"or"UTF8".-Vโ report thetmuxversion. โจ-vโ request verbose logging. log messages get saved intotmux-client-PID.logandtmux-server-PID.logfiles in the current directory, wherePIDis the PID of the server or client process. if you specify-vtwice, an additionaltmux-out-PID.logfile is generated, containing a copy of everythingtmuxwrites to the terminal. ๐
you can send the SIGUSR2 signal to the tmux server process to toggle logging between on (as if -v was given) and off.
command [flags]โ this specifies one of a set of commands used to controltmux, as described in the following sections. if no commands are specified, the command indefault-client-commandis assumed, which defaults tonew-session.
๐ DEFAULT KEY BINDINGS ๐
tmux can be controlled from an attached client using a key combination of a prefix key โ โC-bโ (Ctrl-b) by default โ followed by a command key. it's a little two-step, but she eats every time. ๐
the default command key bindings are:
C-bโ send the prefix key (C-b) through to the application.C-oโ rotate the panes in the current window forwards.C-zโ suspend thetmuxclient.!โ break the current pane out of the window."โ split the current pane into two, top and bottom.#โ list all paste buffers.$โ rename the current session.%โ split the current pane into two, left and right.&โ kill the current window.'โ prompt for a window index to select.(โ switch the attached client to the previous session.)โ switch the attached client to the next session.*โ create a new floating pane.,โ rename the current window.-โ delete the most recently copied buffer of text..โ prompt for an index to move the current window.0to9โ select windows0to9.:โ enter thetmuxcommand prompt.;โ move to the previously active pane.=โ choose which buffer to paste interactively from a list.?โ list all key bindings.Dโ choose a client to detach.Lโ switch the attached client back to the last session.[โ enter copy mode to copy text or view the history.]โ paste the most recently copied buffer of text.cโ create a new window.dโ detach the current client.fโ prompt to search for text in open windows.iโ display some information about the current window.lโ move to the previously selected window.mโ mark the current pane (seeselect-pane -m).Mโ clear the marked pane.nโ change to the next window.oโ select the next pane in the current window.pโ change to the previous window.qโ briefly display pane indexes.rโ force redraw of the attached client.sโ select a new session for the attached client interactively.tโ show the time. โฐTโ change the current pane title.wโ choose the current window interactively.xโ kill the current pane.zโ toggle zoom state of the current pane.Tabโ choose a new window and session by fuzzy matching.{โ swap the current pane with the previous pane.}โ swap the current pane with the next pane.g 1,2,3,4andg Up,Down,Left,Rightโ move floating pane to corners or edges.Metaresizes the pane as well.~โ show previous messages fromtmux, if any.Page Upโ enter copy mode and scroll one page up.Up,Down,Left,Rightโ change to the pane above, below, to the left, or to the right of the current pane.M-1toM-7โ arrange panes in one of the seven preset layouts:even-horizontal,even-vertical,main-horizontal,main-horizontal-mirrored,main-vertical,main-vertical-mirrored, ortiled.Spaceโ arrange the current window in the next preset layout.M-nโ move to the next window with a bell or activity marker.M-oโ rotate the panes in the current window backwards.M-pโ move to the previous window with a bell or activity marker.C-Up,C-Down,C-Left,C-Rightโ resize the current pane in steps of one cell.M-Up,M-Down,M-Left,M-Rightโ resize the current pane in steps of five cells.
key bindings may be changed with the bind-key and unbind-key commands. ๐
and bestieโฆ we are SO not done. there are 23 more parts of this whole entire saga coming your way. ๐โจ
โจ COMMAND PARSING AND EXECUTION โจ
okay bestie, so tmux has a whole library of commands it uses to control itself. Each one has a name and can take zero or more flags and arguments. You can bind them to a key with the bind-key command, or run them straight from your shell prompt, a shell script, a configuration file, or the command prompt. ๐ซถ
Like, the exact same set-option command run from the shell prompt, from ~/.tmux.conf, and bound to a key can look like this:
$ tmux set-option -g status-style bg=cyan
set-option -g status-style bg=cyan
bind-key C set-option -g status-style bg=cyan
So here the command name is set-option, -g is a flag, and status-style and bg=cyan are arguments. no cap ๐
Now โ tmux is lowkey a huge nerd and it splits "command parsing" from "execution". To actually execute a command, tmux needs it broken up into its name + arguments first. That first bit is command parsing. And here's the vibe check: if you run a command from the shell, your shell parses it. If it comes from inside tmux or from a config file, tmux does the parsing. ๐
Times when tmux is the one parsing:
- in a configuration file;
- typed at the command prompt (see
command-prompt); - given to
bind-key; - passed as arguments to
if-shellorconfirm-before.
To execute commands, every client has its own โcommand queueโ. There's also a global command queue that isn't attached to any client, and it gets used on startup for config files like ~/.tmux.conf. Parsed commands get added to the queue and run in order. ๐ฆ
Some commands โ looking at you, if-shell and confirm-before โ parse their argument to make a new command, and that new command is inserted immediately after themselves. Which means arguments can get parsed twice or even more: once when the parent command (like if-shell) is parsed, and again when it parses and executes its own command. iconic behaviour honestly ๐ญ
And some commands โ if-shell, run-shell and display-panes โ will literally stop execution of the subsequent commands on the queue until something happens. For if-shell and run-shell that something is a shell command finishing; for display-panes it's a key being pressed. โธ๏ธ
Example time! These commands:
new-session; new-window
if-shell "true" "split-window"
kill-session
Will execute new-session, new-window, if-shell, the shell command true(1), split-window and kill-session in that order. โจ
The โCOMMANDSโ section lists the tmux commands and their arguments.
๐ PARSING SYNTAX ๐
This section is all about the syntax of commands parsed by tmux โ so like, in a configuration file or at the command prompt. Heads up though: when commands are entered into the shell, they get parsed by the shell instead โ see for example ksh(1) or csh(1). ๐ธ
Every command gets terminated by a newline or a semicolon (;). Commands separated by semicolons together form a โcommand sequenceโ โ and if one command in that sequence hits an error, none of the following commands run. periodt ๐
It's recommended that a semicolon used as a command separator should be written as an individual token, for example from sh(1):
$ tmux neww \; splitw
Or:
$ tmux neww ';' splitw
Or from the tmux command prompt:
neww ; splitw
However, a trailing semicolon is also interpreted as a command separator, for example in these sh(1) commands:
$ tmux neww\; splitw
Or:
$ tmux 'neww;' splitw
So like the examples show, when you're running tmux from the shell you have to be extra careful with quoting semicolons:
- Semicolons that should be interpreted as a command separator should be escaped according to the shell conventions. For
sh(1)this typically means quoted (such asneww ';' splitw) or escaped (such asneww \; splitw). - Individual semicolons or trailing semicolons that should be interpreted as arguments should be escaped twice: once according to the shell conventions and a second time for tmux; for example:
$ tmux neww 'foo\;' bar
$ tmux neww foo\\\; bar
- Semicolons that are not individual tokens or trailing another token should only be escaped once according to shell conventions; for example:
$ tmux neww 'foo-;-bar'
$ tmux neww foo-\;-bar
Comments are marked by the unquoted # character โ anything left on the line after a comment is ignored until the end of the line. ๐ฌ
If the last character of a line is \, that line gets joined with the following line (the \ and the newline are completely removed). This is called line continuation and it applies both inside and outside quoted strings and in comments โ but not inside braces. ๐ง
Command arguments can be written as strings surrounded by single (') quotes or double (") quotes, or as command lists surrounded by braces ({}). You need this when the argument contains any special character. Single and double quoted strings can't span multiple lines except with line continuation. Braces, though? Braces can totally span multiple lines. slay ๐
Outside of quotes, and inside double quotes, these replacements happen:
- Environment variables preceded by
$are replaced with their value from the global environment (see the โGLOBAL AND SESSION ENVIRONMENTโ section). - A leading
~or~useris expanded to the home directory of the current or specified user. \uXXXXor\uXXXXXXXXis replaced by the Unicode codepoint corresponding to the given four or eight digit hexadecimal number.- When preceded (escaped) by a
\, the following characters are replaced:\eby the escape character;\rby a carriage return;\nby a newline; and\tby a tab. \ooois replaced by a character of the octal value ooo. Three octal digits are required, for example\001. The largest valid character is\377.- Any other characters preceded by
\are replaced by themselves (that is, the\is removed) and are not treated as having any special meaning โ so for example\;will not mark a command sequence and\$will not expand an environment variable.
Braces get parsed as a configuration file (so conditions such as โ%ifโ are processed) and then converted into a string. They're designed to avoid needing extra escaping when you pass a group of tmux commands as an argument (for example to if-shell). These two examples produce an identical command โ and note that no escaping is needed when using {}: ๐
if-shell true {
display -p 'brace-dollar-foo: }$foo'
}
if-shell true "display -p 'brace-dollar-foo: }\$foo'"
Braces may be enclosed inside braces, for example:
bind x if-shell "true" {
if-shell "true" {
display "true!"
}
}
Environment variables can be set using the syntax โname=valueโ, for example โHOME=/home/userโ. Variables set during parsing are added to the global environment. A hidden variable may be set with โ%hiddenโ, for example:
%hidden MYVAR=42
Hidden variables are not passed to the environment of processes created by tmux. See the โGLOBAL AND SESSION ENVIRONMENTโ section. ๐
Commands may be parsed conditionally by surrounding them with โ%ifโ, โ%elifโ, โ%elseโ and โ%endifโ. The argument to โ%ifโ and โ%elifโ is expanded as a format (see โFORMATSโ) and if it evaluates to false (zero or empty), subsequent text is ignored until the closing โ%elifโ, โ%elseโ or โ%endifโ. For example:
%if "#{==:#{host},myhost}"
set -g status-style bg=red
%elif "#{==:#{host},myotherhost}"
set -g status-style bg=green
%else
set -g status-style bg=blue
%endif
Will change the status line to red if running on โmyhostโ, green if running on โmyotherhostโ, or blue if running on another host. ๐จ
Conditionals may be given on one line too, for example:
%if #{==:#{host},myhost} set -g status-style bg=red %endif
โจ COMMANDS โจ
okay bestie this is the big one ๐ this whole section is the commands tmux supports. Most of them take an optional -t argument (and sometimes -s too) with one of target-client, target-session, target-window, or target-pane โ those are just fancy ways of saying which client, session, window or pane the command should mess with ๐
target-client should be the name of the client, usually the pty(4) file the client is connected to โ so like /dev/ttyp1 or ttyp1 for the client attached to /dev/ttyp1, either one works. If you don't specify a client, tmux tries to figure out which one you're currently using, and if that fails it just reports an error ๐ญ. You can list clients with the list-clients command.
target-session gets tried in this order:
- A session ID prefixed with a
$. - An exact name of a session (as listed by the
list-sessionscommand). - The start of a session name โ so like
mysesswould match a session namedmysession. - A
glob(7)pattern which is matched against the session name.
If the session name is prefixed with an =, only an exact match counts, periodt. So =mysess will only match exactly mysess, not mysession, no exceptions ๐ธ
If a single session is found, that's your target session. Multiple matches = error, bestie ๐. And if a session is omitted entirely, the current session is used if there is one; if there's no current session available, the most recently used one gets picked ๐
target-window (or src-window or dst-window) specifies a window in the form session:window. The session part follows the same rules as target-session, and window gets looked for in this order:
- A special token, listed below.
- A window index โ so
mysession:1is window1in sessionmysession. - A window ID, such as
@1. - An exact window name, such as
mysession:mywindow. - The start of a window name, such as
mysession:mywin. - As a
glob(7)pattern matched against the window name.
Same as with sessions, a = prefix means exact match only ๐. An empty window name specifies the next unused index if that's appropriate (like for the new-window and link-window commands), otherwise the current window in session is chosen.
These special tokens are available to point at particular windows. Each one has a single-character alternative form too ๐ฆ
{start}/^โ the lowest-numbered window{end}/$โ the highest-numbered window{last}/!โ the last (previously current) window{next}/+โ the next window by number{previous}/-โ the previous window by number{current}/@โ the current window{mouse}/=โ the window where the mouse event happened
target-pane (or src-pane or dst-pane) can be a pane ID, or it takes a similar form to target-window but with the optional addition of a period followed by a pane index or pane ID, like for example mysession:mywindow.1 ๐. If you leave the pane index out, the currently active pane in the specified window is used. These special tokens work for the pane index:
{last}/!โ the last (previously active) pane{next}/+โ the next pane by number{previous}/-โ the previous pane by number{top}โ the top pane{bottom}โ the bottom pane{left}โ the leftmost pane{right}โ the rightmost pane{top-left}โ the top-left pane{top-right}โ the top-right pane{bottom-left}โ the bottom-left pane{bottom-right}โ the bottom-right pane{up-of}โ the pane above the active pane{down-of}โ the pane below the active pane{left-of}โ the pane to the left of the active pane{right-of}โ the pane to the right of the active pane{active}/@โ the active pane{marked}/~โ the marked pane{mouse}/=โ the pane where the mouse event happened
The tokens + and - may be followed by an offset, like this bestie:
select-window -t:+2
Also!! target-session, target-window or target-pane can consist entirely of the token {mouse} (alternative form =) to specify the session, window or pane where the most recent mouse event occurred (check the โMOUSE SUPPORTโ section), or {marked} (alternative form ~) to specify the marked pane (check select-pane -m) ๐ญโจ
Sessions, windows and panes are each numbered with a unique ID โ session IDs are prefixed with a $, windows with a @, and panes with a % ๐
. These are unique and stay unchanged for the whole life of the session, window or pane in the tmux server, fr fr. The pane ID gets passed to the child process of the pane in the TMUX_PANE environment variable ๐. IDs can be displayed using the session_id, window_id, or pane_id formats (see the โFORMATSโ section) and the display-message, list-sessions, list-windows or list-panes commands.
target-session, target-window or target-pane each denote the โtypeโ of target the command needs to work on. If a target isn't explicitly qualified using : and ., tmux will pick whatever seems like the best choice available ๐. For example, if a target-pane of 1 is used with a current window that has only one pane, tmux knows that the 1 can't mean a pane, so it'll look for the active pane in window 1, or the active pane in the current window in session 1. Only if none of those are there will it report an error ๐. If it really matters that a specific pane, window or session always gets used โ like from a script โ the target should be fully qualified (for example a target-pane of -t:.1), or else pane, window or session IDs should be used. Don't be sloppy, bestie ๐ซถ
shell-command arguments are sh(1) commands. This may be a single argument passed to the shell, for example:
new-window 'vi ~/.tmux.conf'
Will run:
/bin/sh -c 'vi ~/.tmux.conf'
Unless specified, tmux uses the value of default-shell in place of /bin/sh ๐ธ
Also, the new-window, new-session, split-window, respawn-window, respawn-pane and display-popup commands allow shell-command to be given as multiple arguments and executed directly (without sh -c) ๐. This can dodge issues with shell quoting, iconic honestly. For example:
$ tmux new-window vi ~/.tmux.conf
Will run vi(1) directly without invoking the shell โจ
command [argument ...] refers to a tmux command, either passed with the command and arguments separately, for example:
bind-key F1 set-option status off
Or passed as a single string argument in .tmux.conf, for example:
bind-key F1 { set-option status off }
Example tmux commands include:
refresh-client -t/dev/ttyp2
rename-session -tfirst newname
set-option -wt:0 monitor-activity on
new-window ; split-window -d
bind-key R source-file ~/.tmux.conf \; \
display-message "source-file done"
Or from sh(1):
$ tmux kill-window -t :1
$ tmux new-window \; split-window -d
$ tmux new-session -d 'vi ~/.tmux.conf' \; split-window -d \; attach
๐ซถ CLIENTS AND SESSIONS ๐ซถ
The tmux server manages clients, sessions, windows and panes, bestie ๐. Clients are attached to sessions to interact with them โ either when they're created with the new-session command, or later with the attach-session command. Each session has one or more windows linked into it. Windows may be linked to multiple sessions, and they're made up of one or more panes, each of which contains a pseudo terminal ๐. Commands for creating, linking and otherwise manipulating windows live in the โWINDOWS AND PANESโ section.
The following commands are available to manage clients and sessions ๐ฆ
attach-session [-dErx] [-c working-directory] [-f flags] [-t target-session]โ (alias:attach) If you run it from outsidetmux, attach to target-session in the current terminal. target-session must already exist โ to create a new session, see thenew-sessioncommand (with-Ato create or attach) ๐. If used from inside, it switches the currently attached session over to target-session. If-dis specified, any other clients attached to the session get detached ๐. If-xis given, it sendsSIGHUPto the parent process of the client as well as detaching the client, which typically causes it to exit.-fsets a comma-separated list of client flags. The flags are:ignore-sizeโ the client does not affect the size of other clientsnew-layoutsโ use the new layout string formatno-detach-on-destroyโ do not detach the client when the session it is attached to is destroyed if there are any other sessionsno-outputโ the client does not receive pane output in control modepause-after=secondsโ output is paused once the pane is seconds behind in control moderead-onlyโ the client is read-onlywait-exitโ wait for an empty line input before exiting in control mode
A leading ! turns a flag off if the client is already attached ๐. -r is an alias for -f read-only,ignore-size. When a client is read-only, only keys bound to the detach-client or switch-client commands have any effect. That's it. Nothing else works. Respect the read-only era ๐
If no server is started, attach-session will attempt to start it โ but this will fail unless sessions are created in the configuration file ๐ญ
The target-session rules for attach-session are slightly adjusted: if tmux needs to select the most recently used session, it will prefer the most recently used unattached session ๐ซถ
-c will set the session working directory (used for new windows) to working-directory.
If -E is used, the update-environment option will not be applied.
detach-client [-aP] [-E shell-command] [-s target-session] [-t target-client]โ (alias:detach) Detach the current client if it's bound to a key, the client specified with-t, or all clients currently attached to the session specified by-s๐ธ. The-aoption kills all but the client given with-t. If-Pis given, it sendsSIGHUPto the parent process of the client, typically causing it to exit ๐. With-E, run shell-command to replace the client โจ
has-session ๐
has-session [-t target-session]
(alias: has)
Bestie, this one is a straight-up vibe check on a session. If the session you named with -t target-session does not exist, it yells at you and bails with exit status 1. If it does exist? Chill, exits 0. That's it, that's the whole job. โจ
kill-server ๐
kill-server
No flags, no mercy โ this one takes out the entire tmux server, every client hanging off it, and destroys all the sessions. It's giving scorched earth, fr fr. ๐ญ
kill-session ๐ฅ
kill-session [-aCg] [-f filter] [-t target-session]
This destroys the session you point at with -t target-session โ closes any windows linked to it (and only it), and detaches every client attached to it. Other sessions get to live another day. Slay.
-aโ nuke all the sessions except the one you specified. Bye besties ๐-f filterโ when you're using-a, this sets a filter. Only the sessions where the filter comes back true get killed. So it's a targeted takedown, not a bloodbath.-gโ if that session is part of a session group, then the whole group goes down, not just the one.-Cโ clears alerts (that's bell, activity, or silence) in every window linked to the session. Peace and quiet, periodt.
list-clients ๐
list-clients [-r] [-F format] [-f filter] [-O sort-order] [-t target-session]
(alias: lsc)
Shows you every client currently attached to the server. The whole roster.
-F formatโ picks the format of each line.-f filterโ only clients where the filter is true show up. Filter deets live in the โFORMATSโ section, iykyk.-O sort-orderโ how to sort them. Pick one of:'name','size','creation'(that's time), or'activity'(also time).-rโ reverses the sort order. Flip it and reverse it. ๐-t target-sessionโ if you give this, it only lists clients connected to that session. So specific.
list-commands ๐
list-commands [-F format] [command]
(alias: lscm)
Lists the syntax of command โ or, if you leave it out, of every single command tmux supports. It's the full menu. The -F format flag lets you control the format of what comes back.
list-sessions ๐ธ
list-sessions [-r] [-F format] [-f filter] [-O sort-order]
(alias: ls)
Lists all the sessions the server is managing. Your whole collection, bestie. ๐
-F formatโ sets the format of each line.-f filterโ only sessions where the filter is true show up. Check the โFORMATSโ section for how filters work.-O sort-orderโ sorting time. Choose one of:'index','name','creation'(time), or'activity'(time).-rโ reverses the sort order. The way that flips the whole list around, iconic.
lock-client ๐
lock-client [-t target-client]
(alias: lockc)
Locks target-client. Need the deets on what locking actually does? Go read the lock-server command, girlie.
lock-session ๐โจ
lock-session [-t target-session]
(alias: locks)
Locks all the clients attached to target-session. Every one of them. No entry without the key. ๐
new-session ๐
new-session [-AdDEPX] [-c start-directory] [-e environment] [-f flags]
[-F format] [-n window-name] [-s session-name] [-t group-name]
[-x width] [-y height] [shell-command [argument ...]]
(alias: new)
Creating a whole new session called session-name. Main character origin story. โจ
So the tea: the new session attaches itself to your current terminal unless you pass -d. window-name and shell-command are the name of, and the shell command to run in, that very first window. With -d, the starting size comes from the global default-size option โ and you can override that size with -x and -y. Passing '-' means "use the size of the current client, if there is one." And heads up: if you give -x or -y, the default-size option gets set for the session. -f sets a comma-separated list of client flags (peep attach-session for those).
If you run this from a terminal, any termios(4) special characters get saved and used for new windows in the new session. Cute.
Now the -A flag: it makes new-session behave like attach-session whenever session-name already exists. And if -A is in play, then -D behaves like -d does to attach-session, and -X behaves like -x does to attach-session.
If -t is given, it specifies a session group. Sessions in the same group share the same set of windows โ new windows are linked into every session in the group, and any windows closed get removed from all of them. But the current and previous window, and any session options, stay independent. Any session in a group can be killed without it affecting the others. Group chat, but make it windows. ๐ซถ
The group-name argument can be:
- the name of an existing group โ in which case the new session gets added to that group;
- the name of an existing session โ the new session joins the same group as that session, and a new group gets created if one's needed;
- the name for a brand new group containing only the new session.
-nandshell-commandare invalid if-tis used. Don't do it. ๐ซ
The -P option prints info about the new session once it's been created. By default it uses the format '#{session_name}:', but you can hand it a different format with -F.
If -E is used, the update-environment option will not be applied. And -e takes the form 'VARIABLE=value' and sets an environment variable for the newly created session โ you can use it multiple times if you're feeling extra. ๐
refresh-client ๐ง
refresh-client [-cDlLRSU] [-A pane:state] [-B name:what:format] [-C
size] [-f flags] [-r pane:report] [-t target-client]
[adjustment]
(alias: refresh)
Refreshes the current client if you've bound this to a key, or refreshes a single client if you point at one with -t. And if -S is specified, it only updates the client's status line โ nothing else, just the glow-up on the bar.
Now here's where it gets spicy. The -U, -D, -L, -R, and -c flags let you change the visible portion of a window that's bigger than the client:
-Umoves the visible part up byadjustmentrows-Dmoves it down-Lmoves it left byadjustmentcolumns-Rmoves it right-csnaps back to tracking the cursor automatically
If adjustment is left out, 1 is used. โ ๏ธ Important caveat bestie: the visible position is a property of the client, not of the window โ so changing the current window in the attached session resets it. Rude, but that's the rule.
-C sizeโ sets the width and height of a control mode client, or of a window for a control mode client.sizehas to be either'widthxheight'or'window ID:widthxheight', like'80x24'or'@0:80x24'.-A pane:stateโ lets a control mode client trigger actions on a pane. The argument is a pane ID (with that leading'%'), then a colon, then one of'on','off','continue'or'pause'.- If
'off',tmuxwill not send output from the pane to the client, and if all clients have turned the pane off, it'll stop reading from the pane. - If
'continue',tmuxgoes back to sending output to the pane if it was paused (whether that was manually or via thepause-afterflag). - If
'pause',tmuxpauses the pane. -Acan be given multiple times for different panes. Stack 'em.
- If
-B name:what:formatโ sets a subscription to a format for a control mode client. The argument gets split into three items by colons:nameis a name for the subscription,whatis a type of item to subscribe to, andformatis the format. Once a subscription is added, changes to the format get reported with the%subscription-changednotification, at most once a second. If you only give thename, the subscription is removed. Andwhatcan be empty to check the format only for the attached session, or it can be one of: a pane ID like'%0';'%*'for all panes in the attached session; a window ID like'@0'; or'@*'for all windows in the attached session.-f flagsโ sets a comma-separated list of client flags. Seeattach-session.-r pane:reportโ lets a control mode client give info about a pane via a report (like the response to OSC 10). The argument is a pane ID (with a leading'%'), a colon, then a report escape sequence.-lโ requests the clipboard from the client using thexterm(1)escape sequence and stashes it in a new paste buffer. ๐-L,-R,-U,-Dโ move the visible portion of the window left, right, up or down byadjustment, if the window is bigger than the client.-cโ resets so the position follows the cursor. Also peep thewindow-sizeoption.
rename-session โ๏ธ
rename-session [-t target-session] new-name
(alias: rename)
Renames the session to new-name. Glow-up complete. ๐
server-access ๐
server-access [-adglrw] [user | group]
Changes the access, or the read/write permission, of a user or group. The user running the tmux server (its owner) and the root user cannot be changed and are always permitted access. -g changes a group rather than a user.
-aand-dโ give or revoke access for the specifieduserorgroup. And if a client is already attached,-dcauses it to be detached unless it's still permitted by another entry. Sneaky but fair.-rand-wโ change the permissions foruserorgroup.-rmakes matching clients read-only,-wmakes them writable.-lโ lists the current access permissions. User entries show with'U', group entries with'G', and read-only or writable entries with'R'or'W'โ for example'user1 (U,W)'or'testgroup (G,R)'. If both a user entry and a group entry match a client, the user entry takes precedence. And heads up: only the effective group ID of the client is used, not its supplementary groups.
By default the access list is empty, and tmux creates sockets with file system permissions that prevent access by any user other than the owner (and root). Those permissions have to be changed manually. And bestie, listenโ
Great care should be taken not to allow access to untrusted users even read-only. โ ๏ธ
show-messages ๐จ
show-messages [-JT] [-t target-client]
(alias: showmsgs)
Shows server messages or info. Messages get stored, up to a maximum โ that max is set by the message-limit server option. -J and -T show debugging information about jobs and terminals. ๐ ๏ธ
source-file ๐
source-file [-Fnqv] [-t target-pane] path ...
(alias: source)
Runs commands from one or more files given by path โ and yes, path can be glob(7) patterns. ๐
-Fโ if present,pathgets expanded as a format.-qโ if given, no error is returned whenpathdoesn't exist. No yelling, just vibes.-nโ the file is parsed but no commands are executed. Window shopping only.-vโ shows the parsed commands and line numbers, if possible.
start-server โญ
start-server
(alias: start)
Starts the tmux server โ if it isn't already running โ without creating any sessions. Just the server, standing there, ready.
Note that since by default thetmuxserver will exit with no sessions, this is only useful if a session is created in~/.tmux.conf, ifexit-emptyis turned off, or if another command is run as part of the same command sequence.
For example:
$ tmux start \; show -g
suspend-client ๐ด
suspend-client [-t target-client] (alias: suspendc)
Suspend a client by sending SIGTSTP (tty stop). Like, it literally tells the client to take a lil nap, bestie. ๐ค
switch-client ๐
switch-client [-ElnprZ] [-c target-client] [-O sort-order] [-t target-session] [-T key-table]
(alias: switchc)
Switch the current session for client target-client to target-session. But okay, plot twist: as a special case, -t may refer to a pane (a target that contains :, . or %), to change session, window and pane. In that case, -Z keeps the window zoomed if it was zoomed. If -l, -n or -p is used, the client is moved to the last, next or previous session respectively. -O may be used with -n and -p to specify the field to sort on: one of name, size, creation (time), or activity (time). -r toggles the client read-only and ignore-size flags (see the attach-session command).
If -E is used, the update-environment option will not be applied.
-T sets the client's key table; the next key will be looked up using key-table. After that key, the client is returned to its default key table (normally root). This may be used to configure multiple prefix keys, or to bind commands to sequences of keys. For example, to make typing abc run the list-keys command:
bind-key -Ttable2 c list-keys
bind-key -Ttable1 b switch-client -Ttable2
bind-key -Troot a switch-client -Ttable1
WINDOWS AND PANES ๐ชโจ
Each window displayed by tmux may be split into one or more panes; each pane takes up a certain area of the display and is a separate terminal. A window may be split into panes using the split-window command. Windows may be split horizontally (with the -h flag) or vertically. Panes may be resized with the resize-pane command (bound to C-Up, C-Down C-Left and C-Right by default), the current pane may be changed with the select-pane command and the rotate-window and swap-pane commands may be used to swap panes without changing their position. Panes are numbered beginning from zero in the order they are created. Periodt. ๐
By default, a tmux pane permits direct access to the terminal contained in the pane. A pane may also be put into one of several modes:
- Copy mode โ which permits a section of a window or its history to be copied to a paste buffer for later insertion into another window. This mode is entered with the
copy-modecommand, bound to[by default. Copied text can be pasted with thepaste-buffercommand, bound to]. ๐ - View mode โ which is like copy mode but is entered when a command that produces output, such as
list-keys, is executed from a key binding. ๐ - Choose mode โ which allows an item to be chosen from a list. This may be a client, a session or window or pane, or a buffer. This mode is entered with the
choose-buffer,choose-clientandchoose-treecommands. ๐
In copy mode an indicator is displayed in the top-right corner of the pane with the current position and the number of lines in the history. It's giving very "you are here" energy. ๐
Commands are sent to copy mode using the -X flag to the send-keys command. When a key is pressed, copy mode automatically uses one of two key tables, depending on the mode-keys option: copy-mode for emacs, or copy-mode-vi for vi. Key tables may be viewed with the list-keys command. ๐๏ธ
The following commands are supported in copy mode:
append-selectionโ Append the selection to the top paste buffer. Just stack it on top, bestie.append-selection-and-cancel(vi: A)โ Append the selection to the top paste buffer and exit copy mode. Bye! ๐back-to-indentation(vi: ^)(emacs: M-m)โ Move the cursor back to the indentation. ๐งbegin-selection(vi: Space)(emacs: C-Space)โ Begin selection. โจbottom-line(vi: L)โ Move to the bottom line. โฌ๏ธcancel(vi: q)(emacs: Escape)โ Exit copy mode. ๐ชclear-selection(vi: Escape)(emacs: C-g)โ Clear the current selection. ๐งฝcopy-end-of-line [-CP] [prefix]โ Copy from the cursor position to the end of the line. prefix is used to name the new paste buffer. ๐copy-end-of-line-and-cancel [-CP] [prefix]โ Copy from the cursor position and exit copy mode. ๐โโ๏ธcopy-pipe-end-of-line [-CP] [command] [prefix]โ Copy from the cursor position to the end of the line and pipe the text to command. prefix is used to name the new paste buffer. ๐ฐcopy-pipe-end-of-line-and-cancel [-CP] [command] [prefix]โ Same ascopy-pipe-end-of-linebut also exit copy mode. ๐copy-line [-CP] [prefix]โ Copy the entire line. โcopy-line-and-cancel [-CP] [prefix]โ Copy the entire line and exit copy mode. ๐ชcopy-pipe-line [-CP] [command] [prefix]โ Copy the entire line and pipe the text to command. prefix is used to name the new paste buffer. ๐ฐcopy-pipe-line-and-cancel [-CP] [command] [prefix]โ Same ascopy-pipe-linebut also exit copy mode. ๐copy-pipe [-CP] [command] [prefix]โ Copy the selection, clear it and pipe its text to command. prefix is used to name the new paste buffer. ๐ฐcopy-pipe-no-clear [-CP] [command] [prefix]โ Same ascopy-pipebut do not clear the selection. ๐ โโ๏ธcopy-pipe-and-cancel [-CP] [command] [prefix]โ Same ascopy-pipebut also exit copy mode. ๐copy-selection [-CP] [prefix]โ Copies the current selection. ๐copy-selection-no-clear [-CP] [prefix]โ Same ascopy-selectionbut do not clear the selection. ๐ โโ๏ธcopy-selection-and-cancel [-CP] [prefix](vi: Enter)(emacs: M-w)โ Copy the current selection and exit copy mode. ๐cursor-down(vi: j)(emacs: Down)โ Move the cursor down. โฌ๏ธcursor-down-and-cancelโ Same ascursor-downbut also exit copy mode if reaching the bottom. ๐cursor-left(vi: h)(emacs: Left)โ Move the cursor left. โฌ ๏ธcursor-right(vi: l)(emacs: Right)โ Move the cursor right. โก๏ธcursor-up(vi: k)(emacs: Up)โ Move the cursor up. โฌ๏ธcursor-centre-vertical(emacs: C-l)โ Moves the cursor to the vertical centre of the pane. ๐ฏcursor-centre-horizontal(emacs: M-l)โ Moves the cursor to the horizontal centre of the pane. ๐ฏend-of-line(vi: $)(emacs: C-e)โ Move the cursor to the end of the line. ๐goto-line line(vi: :)(emacs: g)โ Move the cursor to a specific line. ๐งญhalfpage-down(vi: C-d)(emacs: M-Down)โ Scroll down by half a page. ๐halfpage-down-and-cancelโ Same ashalfpage-downbut also exit copy mode if reaching the bottom. ๐halfpage-up(vi: C-u)(emacs: M-Up)โ Scroll up by half a page. ๐history-bottom(vi: G)(emacs: M->)โ Scroll to the bottom of the history. โฌhistory-top(vi: g)(emacs: M-<)โ Scroll to the top of the history. โซjump-again(vi: ;)(emacs: ;)โ Repeat the last jump. ๐jump-backward to(vi: F)(emacs: F)โ Jump backwards to the specified text. โฌ ๏ธjump-forward to(vi: f)(emacs: f)โ Jump forward to the specified text. โก๏ธjump-reverse(vi: ,)(emacs: ,)โ Repeat the last jump in the reverse direction (forward becomes backward and backward becomes forward). ๐jump-to-backward to(vi: T)โ Jump backwards, but one character less, placing the cursor on the character after the target. ๐ฏjump-to-forward to(vi: t)โ Jump forward, but one character less, placing the cursor on the character before the target. ๐ฏjump-to-mark(vi: M-x)(emacs: M-x)โ Jump to the last mark. ๐line-numbers-onโ Show line numbers in copy mode. ๐ขline-numbers-offโ Hide line numbers in copy mode. ๐line-numbers-toggle(emacs: L)โ Toggle line numbers in copy mode. ๐ขmiddle-line(vi: M)(emacs: M-r)โ Move to the middle line. ๐ฏnext-matching-bracket(vi: %)(emacs: M-C-f)โ Move to the next matching bracket. ๐งฉnext-paragraph(vi: })(emacs: M-})โ Move to the next paragraph. ๐next-prompt [-o]โ Move to the next prompt. โก๏ธnext-word(vi: w)โ Move to the next word. ๐next-word-end(vi: e)(emacs: M-f)โ Move to the end of the next word. ๐next-space(vi: W)โ Same asnext-wordbut treat all non-whitespace characters as part of a word. ๐งตnext-space-end(vi: E)โ Same asnext-word-endbut treat all non-whitespace characters as part of a word. ๐งตother-end(vi: o)โ Switch at which end of the selection the cursor sits. ๐page-down(vi: C-f)(emacs: PageDown)โ Scroll down by one page. ๐page-down-and-cancelโ Same aspage-downbut also exit copy mode if reaching the bottom. ๐page-up(vi: C-b)(emacs: PageUp)โ Scroll up by one page. ๐pipe [command]โ Pipe the selected text to command and clear the selection. ๐ฐpipe-no-clear [command]โ Same aspipebut do not clear the selection. ๐ โโ๏ธpipe-and-cancel [command] [prefix]โ Same aspipebut also exit copy mode. ๐previous-matching-bracket(emacs: M-C-b)โ Move to the previous matching bracket. ๐งฉprevious-paragraph(vi: {)(emacs: M-{)โ Move to the previous paragraph. ๐previous-prompt [-o]โ Move to the previous prompt. โฌ ๏ธprevious-word(vi: b)(emacs: M-b)โ Move to the previous word. ๐previous-space(vi: B)โ Same asprevious-wordbut treat all non-whitespace characters as part of a word. ๐งตrectangle-onโ Turn on rectangle selection mode. ๐ฒrectangle-offโ Turn off rectangle selection mode. ๐ณrectangle-toggle(vi: v)(emacs: R)โ Toggle rectangle selection mode. ๐ฒrecentre-top-bottom(emacs : C-l)โ Cycles the current line between centre, top, and bottom. ๐refresh-onโ Turn on automatic refresh of the content from the pane, so that new output appears while in copy mode. Automatic refresh is off by default; it will scroll only while the cursor is at the bottom and is paused while a selection is in progress. ๐refresh-offโ Turn off automatic refresh of the content from the pane. โธ๏ธrefresh-now(vi: r)(emacs: r)โ Refresh the content from the pane once. ๐refresh-toggleโ Toggle automatic refresh of the content from the pane. ๐scroll-bottomโ Scroll up until the current line is at the bottom while keeping the cursor on that line. โฌ๏ธscroll-down(vi:C-e) (emacs:C-Down) โ scroll down, bestie. Whenmode-keysisvi, the cursor stays fixed relative to the text. ๐ซscroll-down-and-cancelโ literallyscroll-downbut it also dips out of copy mode if the cursor hits the bottom.scroll-exit-onโ turn ON the "exit copy mode when you scroll to the end of the buffer" behaviour โ unless a selection is present, bc we're not gonna yeet your selection, no ma'am.scroll-exit-offโ turn that same exit-when-you-reach-the-end thing OFF. ๐scroll-exit-toggleโ toggle it, iconically.scroll-middle(vi:z) โ scroll so the current line becomes the middle one, while keeping the cursor planted right there on that line. main character centering. ๐scroll-to-mouseโ scrolls the pane in copy-mode when it's bound to a mouse drag event.-emakes copy mode bail out when you're at the bottom.scroll-topโ scroll down until the current line sits at the top, cursor still chillin' on it.scroll-up(vi:C-y) (emacs:C-Up) โ scroll up. Ifmode-keysisvi, the cursor is fixed relative to the text.search-again(vi:n) (emacs:n) โ run the last search again, fr fr.search-backwardtext (vi:?) โ search backwards for the text you specified.search-backward-incrementaltext (emacs:C-r) โ search backwards incrementally for the specified text. This one is expected to be used with the-iflag to thecommand-promptcommand. ๐งsearch-backward-texttext โ search backwards for the specified plain text.search-forwardtext (vi:/) โ search forward for the specified text.search-forward-incrementaltext (emacs:C-s) โ search forward incrementally for the specified text. Again: expected to be used with the-iflag to thecommand-promptcommand.search-forward-texttext โ search forward for the specified plain text.search-reverse(vi:N) (emacs:N) โ repeat the last search but backwards-ways: forward becomes backward and backward becomes forward. ๐select-line(vi:V) โ select the current line.select-wordโ select the current word.selection-mode[char|word|line] โ change the selection mode.set-mark(vi:X) (emacs:X) โ mark the current line.start-of-line(vi:0) (emacs:C-a) โ move the cursor to the start of the line.stop-selectionโ stop selecting, but without clearing the current selection you already have. ๐toggle-position(vi:P) (emacs:P) โ toggle whether the position indicator in the top right is visible.top-line(vi:H) (emacs:M-R) โ move to the top line.
Okay so the search commands come in several varieties, and this is important, so lock in: โsearch-forwardโ and โsearch-backwardโ search for a regular expression. The โ-textโ variants search for a plain text string instead of a regular expression. The โ-incrementalโ ones do an incremental search and expect to be used with the -i flag to the command-prompt command. โsearch-againโ repeats the last search, and โsearch-reverseโ does the same thing but flips the direction (forward becomes backward and backward becomes forward). ๐
The default incremental search key bindings, โC-rโ and โC-sโ, are designed to emulate emacs(1). When you first press them they let you type in a new search term; if you press them with an empty search term they repeat the previously used search term. chef's kiss emulation. ๐ญ
The โnext-promptโ and โprevious-promptโ move between shell prompts, but โ plot twist โ they require the shell to emit an escape sequence (\033]133;A\033\\) to tell tmux where the prompts are located. If the shell doesn't do that, these commands will do nothing. The -o flag jumps to the beginning of the command output instead of the shell prompt. Finding the beginning of command output requires the shell to emit an escape sequence (\033]133;C\033\\) to tell tmux where the output begins. If the shell doesn't send these escape sequences, these commands do nothing. periodt. ๐
Copy commands may take an optional buffer prefix argument, and that's what's used to generate the buffer name โ the default is โbufferโ, so buffers end up named โbuffer0โ, โbuffer1โ and so on. Pipe commands take a command argument, which is the command that the selected text gets piped into. โcopy-pipeโ variants also copy the selection. The โ-and-cancelโ variants of some commands exit copy mode after they've completed (for copy commands) or when the cursor reaches the bottom (for scrolling commands). โ-no-clearโ variants do not clear the selection. And all the copy commands can take the -C and -P flags โ -C suppresses setting the terminal clipboard when copying, while -P suppresses adding a paste buffer with the text. ๐
The next and previous word keys skip over whitespace and treat consecutive runs of either word separators or other letters as words. Word separators can be customized with the word-separators session option. Next word moves to the start of the next word, next word end to the end of the next word, and previous word to the start of the previous word. The three next and previous space keys work similarly but treat all non-whitespace characters as part of a word. Setting word-separators to the empty string makes next/previous word equivalent to next/previous space. lowkey elegant. โจ
The jump commands enable quick movement within a line. For instance, typing โfโ followed by โ/โ will move the cursor to the next โ/โ character on the current line. A โ;โ will then jump to the next occurrence. obsessed. ๐ฅ
Commands in copy mode may be prefaced by an optional repeat count. With vi key bindings, a prefix is entered using the number keys; with emacs, the Alt (meta) key and a number begins prefix entry.
The synopsis for the copy-mode command is:
copy-mode [-dekHMqSu] [-s src-pane] [-t target-pane]
- Enter copy mode. ๐ฆ
-uenters copy mode and scrolls one page up, and-done page down.-Hhides the position indicator in the top right.-qcancels copy mode and any other modes.-Mbegins a mouse drag (only valid if bound to a mouse key binding, see โMOUSE SUPPORTโ).-Senters copy-mode and scrolls when bound to a mouse drag event; seescroll-to-mouse.-scopies from src-pane instead of target-pane.-especifies that scrolling to the bottom of the history (to the visible screen) should exit copy mode. This will not happen if a selection is present. And while in copy mode, pressing a key other than those used for scrolling will disable this behaviour. It's intended to allow fast scrolling through a pane's history, like this:
bind PageUp copy-mode -eu
bind PageDown copy-mode -ed
-kkills the pane when the mode is exited.
A number of preset arrangements of panes are available โ these are called layouts, and they're basically the outfit changes of the tmux world. ๐ These may be selected with the select-layout command or cycled with next-layout (bound to โSpaceโ by default); once a layout is chosen, panes within it may be moved and resized as normal.
The following layouts are supported:
even-horizontalโ panes are spread out evenly from left to right across the window.even-verticalโ panes are spread evenly from top to bottom.main-horizontalโ a large (main) pane is shown at the top of the window and the remaining panes are spread from left to right in the leftover space at the bottom. Use themain-pane-heightwindow option to specify the height of the top pane.main-horizontal-mirroredโ the same asmain-horizontalbut mirrored, so the main pane is at the bottom of the window.main-verticalโ a large (main) pane is shown on the left of the window and the remaining panes are spread from top to bottom in the leftover space on the right. Use themain-pane-widthwindow option to specify the width of the left pane.main-vertical-mirroredโ the same asmain-verticalbut mirrored, so the main pane is on the right of the window.tiledโ panes are spread out as evenly as possible over the window in both rows and columns. geometric slay. ๐ง
In addition, select-layout may be used to apply a previously used layout โ the list-windows command displays the layout of each window in a form suitable for use with select-layout. For example:
$ tmux list-windows
0: ksh [159x48]
layout: {"V":2,"L":{"t":"h","w":159,"h":48,"x":0,"y":0,"c":[{"t":"p","w":79,"h":48,"x":0,"y":0,"l":0,"i":0,"I":"%0"},{"t":"p","w":79,"h":48,"x":80,"y":0,"a":true,"i":1,"I":"%2"}]}}
$ tmux select-layout '{"V":2,"L":{"t":"h","w":159,"h":48,"x":0,"y":0,"c":[{"t":"p","w":79,"h":48,"x":0,"y":0,"l":0,"i":0,"I":"%0"},{"t":"p","w":79,"h":48,"x":80,"y":0,"a":true,"i":1,"I":"%2"}]}}'
tmux automatically adjusts the size of the layout for the current window size. Note that a layout cannot be applied to a window with more panes than that from which the layout was originally defined. ๐ซ
Commands related to windows and panes are as follows:
break-pane[-abdPW][-F format][-n window-name][-s src-pane][-t dst-window][-x width][-y height][-X x-position][-Y y-position](alias:breakp) โ break src-pane off from its containing window to make it the only pane in dst-window.
break-pane [-abdPW] [-F format] [-n window-name] [-s src-pane] [-t dst-window] [-x width] [-y height] [-X x-position] [-Y y-position]
(alias: breakp)
With -a or -b, the window is moved to the next index after or before (existing windows are moved if necessary). If -d is given, the new window does not become the current window. The -P option prints information about the new window after it has been created โ by default it uses the format โ#{session_name}:#{window_index}.#{pane_index}โ but a different format may be specified with -F. ๐
If the -W option is given, src-pane is lifted out of the tiled layout and made floating. The -x and -y options set the width and height of the floating pane in columns and lines respectively โ the default is half the window width and a quarter the window height. The -X and -Y options set the position of the upper-left corner of the pane; if omitted, new floating panes are cascaded from the top-left of the window. The -x, -y, -X, and -Y options may be followed by โ%โ to specify a percentage of the window size. ๐
If the pane had previously been floating, the position and sizes are restored from the saved values not specified by the -x, -y, -X, and -Y options.
If -d is given, the active pane is not changed โ it just stays right where it is. The pane must not already be floating or hidden, and the window must not be zoomed.
๐ซง COMMANDS (still going, bestie, we're so back) ๐ซง
capture-pane
capture-pane [-aeFHILpPRqCJMN] [-b buffer-name] [-E end-line] [-S
start-line] [-t target-pane]
alias: capturep
Okay so this one grabs everything that's currently sitting inside a pane. If you pass -p, the output comes straight to stdout, and if you don't, it goes into the buffer you named with -b โ or into a brand new buffer if you didn't name one. ๐พ
-aโ use the alternate screen, and heads up, the history is not accessible when you do. If there's no alternate screen at all, you get an error back, unless you also passed-q.-Mโ same energy as-abut for modes: if the pane is in a mode, this uses the screen for that mode.-eโ include escape sequences for text and background attributes in the output.-Cโ also escapes non-printable characters as octal\xxx.-Tโ ignore trailing positions that don't contain a character.-Nโ preserve trailing spaces at the end of each line.-Jโ preserve trailing spaces and join any wrapped lines. Also,-Jimplies-T, no cap.-Pโ capture only output the pane has received that is the beginning of an as-yet incomplete escape sequence.-Lโ stick the line number at the start of each line.-Iโ include the time each line entered the history, or zero if that's not available.-Fโ include the flags, where:-means no flagsDmeans an unused lineOmeans a line marked as outputPmeans a line marked as a promptXmeans a line containing extended cellsHmeans a line with hyperlinks
-Hโ only hyperlinks in the specified lines get captured. If a line has multiple hyperlinks, they're separated by spaces.-Rโ dumps the internal grid data, for diagnostics. (nerd mode activated ๐ฌ)
And now the line range stuff, because this is where it gets spicy:
-Sand-Eset the starting and ending line numbers. Zero is the first line of the visible pane, and negative numbers are lines in the history. Give-to-Sand that's the start of the history; give-to-Eand that's the end of the visible pane. By default? You only capture the visible contents of the pane, bestie. Nothing more.
choose-client
choose-client [-hkNryZ] [-F format] [-f filter] [-K key-format] [-O
sort-order] [-t target-pane] [template]
This throws a pane into client mode, where you can pick a client interactively off a list. Each client gets one line. A shortcut key shows up on the left in brackets so you can just grab one instantly, or you can navigate the list and choose / mess with an item using the keys below. ๐
-Zโ zooms the pane.-yโ disables any confirmation prompts.
The keys you can use in client mode:
Enterโ choose the selected clientUpโ select the previous clientDownโ select the next clientC-sโ search by namenโ repeat last search forwardsNโ repeat last search backwardstโ toggle whether the client is taggedTโ tag no clientsC-tโ tag all clientsdโ detach the selected clientDโ detach the tagged clientsxโ detach and HUP the selected clientXโ detach and HUP the tagged clientszโ suspend the selected clientZโ suspend the tagged clientsfโ enter a format to filter itemscโ clear the current filterOโ change sort orderrโ reverse sort ordervโ toggle previewiโ change view (preview and client information)F1orC-hโ display helpqโ exit mode
Once a client is chosen, %% gets swapped out for the client name inside template, and the whole thing runs as a command. If you didn't give a template, then "detach-client -t '%%'" is what gets used. ๐ซถ
-Oโ sets the initial sort order, one ofname,size,creation(time), oractivity(time).-rโ reverses the sort order.-fโ sets an initial filter. The filter is a format: if it evaluates to zero, that item in the list is not shown; otherwise it is shown. And if a filter would lead to an empty list, it's just ignored.-Fโ the format for each item in the list.-Kโ a format for each shortcut key. Both-Fand-Kare evaluated once for each line.
More flags:
-Nโ starts without the preview, or if you give it twice, starts with the larger preview.-hโ hides the pane containing the mode.-kโ kills the pane when the mode is exited.
Heads up: the choose-client command works only if at least one client is attached. No clients, no mode. ๐
choose-tree
choose-tree [-GhikNrswyZ] [-F format] [-f filter] [-K key-format] [-O
sort-order] [-t target-pane] [template]
This one drops a pane into tree mode, where you can pick a session, window or pane out of a tree, interactively. Each session, window or pane is one line. Shortcut key shows up on the left in brackets for instant grabbing, or navigate the tree and choose / manipulate an item with the keys below. ๐ณโจ
-sโ starts with sessions collapsed.-wโ starts with windows collapsed.-Zโ zooms the pane.-yโ disables any confirmation prompts.
The keys for tree mode:
Enterโ choose the selected itemUpโ select the previous itemDownโ select the next itemS-Upโ swap the current window with the previous oneS-Downโ swap the current window with the next one+โ expand the selected item-โ collapse the selected itemM-+โ expand all itemsM--โ collapse all itemsxโ kill the selected itemXโ kill the tagged items<โ scroll the list of previews left>โ scroll the list of previews rightC-sโ search by namemโ set the marked paneMโ clear the marked panenโ repeat last search forwardsNโ repeat last search backwardstโ toggle whether the item is taggedTโ tag no itemsC-tโ tag all items:โ run a command for each tagged itemfโ enter a format to filter itemscโ clear the current filterHโ jump to the starting paneOโ change sort orderrโ reverse sort ordervโ toggle previewiโ change view (preview and session, window and pane information)F1orC-hโ display helpqโ exit mode
After a session, window or pane is chosen: the first instance of %% and all instances of %1 get replaced by the target inside template, and the result runs as a command. If you didn't give a template, "switch-client -t '%%'" is what's used. ๐
-Oโ sets the initial sort order, one ofindex,name,activity(time), orz.-rโ reverses the sort order.-fโ sets an initial filter. The filter is a format: evaluates to zero โ item not shown; otherwise โ shown. If a filter would make an empty list, it's ignored.-Fโ the format for each item in the tree.-Kโ a format for each shortcut key. Again, both are evaluated once for each line.-Gโ include all sessions in any session groups in the tree, instead of only the first one.
And the rest:
-Nโ starts without the preview, or if given twice, with the larger preview.-iโ starts showing client information instead of the preview.-hโ hides the pane containing the mode.-kโ kills the pane when the mode is exited.
-h and -k are literally made to make using this mode inside a floating pane easier. Like, for example:
bind s 'new-pane -x50% -y50% -E; choose-tree -hks'
And the same rule as before: choose-tree works only if at least one client is attached. ๐ซ
customize-mode
customize-mode [-kNZ] [-F format] [-f filter] [-t target-pane]
[template]
Puts a pane into customize mode, where you can browse and modify options and key bindings from a list. The option values shown in the list are for the active pane in the current window. ๐
-Zโ zooms the pane.
The keys you can use in customize mode are:
okay bestie, we're still in customize-mode and the keybindings are absolutely giving main character energy โจ๐ . here's every single one, no cap:
- Enter โ Set pane, window, session or global option value
- Up โ Select previous item
- Down โ Select next item
- + โ Expand selected item
- - โ Collapse selected item
- M-+ โ Expand all items
- M-- โ Collapse all items
- s โ Set option value or key attribute
- S โ Set global option value
- w โ Set window option value, if option is for pane and window
- d โ Set an option or key to the default
- D โ Set tagged options and tagged keys to the default
- e โ Open the value in an editor
- u โ Unset an option (set to default value if global) or unbind a key
- U โ Unset tagged options and unbind tagged keys
- C-s โ Search by name
- n โ Repeat last search forwards
- N โ Repeat last search backwards
- t โ Toggle if item is tagged
- T โ Tag no items
- C-t โ Tag all items
- f โ Enter a format to filter items
- c โ Clear the current filter
- v โ Toggle option information
- F1 or C-h โ Display help
- q โ Exit mode
-f specifies an initial filter: the filter is a format โ if it evaluates to zero, the item in the list is not shown, otherwise it is shown. If a filter would lead to an empty list, it is ignored. -F specifies the format for each item in the tree.
-N starts without the option information. -k kills the pane when the mode is exited.
The customize-mode command works only if at least one client is attached. ๐
switch-mode
switch-mode [-kswZ] [-F format] [-t target-pane] [command]
Put a pane into switch mode, where a session or window may be chosen interactively from a list. Each session or window is shown on one line and the list is narrowed by typing: the typed text is matched against each item with fuzzy matching and only matching items are shown, sorted by how well they match. -s lists sessions (the default) and -w lists windows. -Z zooms the pane. The following keys may be used in switch mode:
- Enter โ Choose the selected item
- Up โ Select the previous item
- Down โ Select the next item
- Escape โ Exit mode
After a session or window is chosen, the first instance of %% and all instances of %1 are replaced by the target in command and the result executed as a command. If command is not given, switch-client -Zt '%%' is used. -F specifies the format for each item in the list. -k kills the pane when the mode is exited.
The appearance of matched characters is controlled by the switch-mode-match-style option. ๐
display-panes
display-panes [-kNZ] [-d duration] [-s source-window] [-t target-pane] [template]
(alias: displayp)
Put target-pane into panes mode, which displays a preview of the window and a visible indicator of each pane. If -s is given, the panes in source-window are displayed instead of those in the window containing target-pane. See the display-panes-colour, display-panes-active-colour, display-panes-border-style, display-panes-format and display-panes-time window options. The indicator is closed when a key is pressed (unless -N is given) or duration milliseconds have passed. If -d is not given, display-panes-time is used. A duration of zero means the indicator stays until a key is pressed. The mode is zoomed by default; -Z starts it unzoomed. -k kills the pane when the mode is exited. While the indicator is on screen, a pane may be chosen with the 0 to 9 keys or by clicking it with the mouse, which will cause template to be executed as a command with %% substituted by the pane ID. The default template is select-pane -t '%%'. ๐ฆ
find-window
find-window [-iCNrTZ] [-t target-pane] match-string
(alias: findw)
Search for a glob(7) pattern or, with -r, regular expression match-string in window names, titles, and visible content (but not history). The flags control matching behavior: -C matches only visible window contents, -N matches only the window name and -T matches only the window title. -i makes the search ignore case. The default is -CNT. -Z zooms the pane.
The find-window command works only if at least one client is attached. โจ
join-pane
join-pane [-bdfhv] [-l size] [-s src-pane] [-t dst-pane]
(alias: joinp)
Like split-window, but instead of splitting dst-pane and creating a new pane, split it and move src-pane into the space. This can be used to reverse break-pane. The -b option causes src-pane to be joined to left of or above dst-pane.
If -s is omitted and a marked pane is present (see select-pane -m), the marked pane is used rather than the current pane.
If src-pane is floating and dst-pane is either unspecified or equal to src-pane, src-pane is returned to its previous position in the layout. ๐
kill-pane
kill-pane [-a] [-f filter] [-t target-pane]
(alias: killp)
Destroy the given pane. If no panes remain in the containing window, it is also destroyed. The -a option kills all panes in the window except the pane given with -t. When -a is given, -f specifies a filter. Only panes for which the filter is true are killed. ๐
kill-window
kill-window [-a] [-f filter] [-t target-window]
(alias: killw)
Kill the current window or the window at target-window, removing it from any sessions to which it is linked. The -a option kills all windows in the session except the window given with -t. When -a is given, -f specifies a filter. Only windows for which the filter is true are killed. ๐
last-pane
last-pane [-deZ] [-t target-window]
(alias: lastp)
Select the last (previously selected) pane. -Z keeps the window zoomed if it was zoomed. -e enables or -d disables input to the pane. ๐
last-window
last-window [-t target-session]
(alias: last)
Select the last (previously selected) window. If no target-session is specified, select the last window of the current session. ๐
link-window
link-window [-abdk] [-s src-window] [-t dst-window]
(alias: linkw)
Link the window at src-window to the specified dst-window. If dst-window is specified and no such window exists, the src-window is linked there. With -a or -b the window is moved to the next index after or before dst-window (existing windows are moved if necessary). If -k is given and dst-window exists, it is killed, otherwise an error is generated. If -d is given, the newly linked window is not selected. ๐
list-panes
list-panes [-ars] [-F format] [-f filter] [-O sort-order] [-t target]
(alias: lsp)
If -a is given, target is ignored and all panes on the server are listed. If -s is given, target is a session (or the current session). If neither is given, target is a window (or the current window). -F specifies the format of each line and -f a filter. Only panes for which the filter is true are shown. See the โFORMATSโ section. -O specifies the sort order: one of name (title), index, size (area), creation (time), or activity (time). -r reverses the sort order. ๐ซถ
list-windows
list-windows [-ar] [-F format] [-f filter] [-O sort-order] [-t target-session]
(alias: lsw)
If -a is given, list all windows on the server. Otherwise, list windows in the current session or in target-session. -F specifies the format of each line and -f a filter. Only windows for which the filter is true are shown. See the โFORMATSโ section. -O specifies the sort order: one of index, name, size (area), creation (time), or activity (time). -r reverses the sort order. ๐
move-pane
move-pane [-bdfhMv] [-D [lines]] [-l size] [-L [columns]] [-P position] [-R [columns]] [-s src-pane] [-t dst-pane] [-U [lines]] [-X x-position] [-Y y-position] [-z z-index]
(alias: movep)
Does the same as join-pane, except if given -D, -L, -P, -R, -U, -X, -Y or -z in which case move the target floating pane. -D, -L, -R and -U move it down, left, right or up by lines or columns (one if omitted). -P moves it to position, which may be one of:
top-leftโ Top lefttop-centreโ Top and horizontal centretop-rightโ Top rightcentre-leftโ Vertical centre and leftcentreโ Centrecentre-rightโ Vertical centre and rightbottom-leftโ Bottom leftbottom-centreโ Bottom and horizontal centrebottom-rightโ Bottom righttop-left-centreโ Centre of top-left quadranttop-right-centreโ Centre of top-right quadrantbottom-left-centreโ Centre of bottom-left quadrantbottom-right-centreโ Centre of bottom-right quadrantfrontโ Front of floating panesbackโ Back of floating panesforwardโ Forward one floating panebackwardโ Backward one floating paneforward-loopโ Forward but back if already at frontbackward-loopโ Backward but front if already at back
-X and -Y move it to an absolute position. -z moves the pane to the given z-index, where zero is the front.
-M begins a mouse drag (only valid if bound to a mouse key binding, see โMOUSE SUPPORTโ). ๐ฑ๏ธ
move-window [-abrdk] [-s src-window] [-t dst-window](alias:movew) โ okay so this is basicallylink-window's sibling but with โจcommitmentโจ: the window at src-window gets moved to dst-window instead of being duplicated. With-r, every window in the session gets renumbered in sequential order, respecting thebase-indexoption. slay.new-window [-abdEkPS] [-c start-directory] [-e environment] [-F format] [-n window-name] [-t target-window] [shell-command [argument ...]](alias:neww) โ bestie, make a new window ๐ With-aor-b, the new window gets inserted at the next index after or before the specified target-window, pushing windows up if necessary; otherwise target-window is literally just where the new window lands.
If -d is given, the session does not make the new window the current window (so it chills in the background, no cap). If -E is given, the initial pane is created without a running command. target-window represents the window to be created; if the target already exists you get an error, unless the -k flag is used, in which case it is destroyed ๐. window-name is the name given to the new window, if any.
If -S is given, an existing window is selected instead of creating a new one (unless -d is also given, in which case the command does nothing at all โ it's giving ghost). target-window is preferred if it already identifies an existing window; otherwise a window named window-name is selected if one exists.
shell-command is the command to execute. If shell-command is not specified, the value of the default-command option is used. -c specifies the working directory in which the new window is created.
When the shell command completes, the window closes. See the remain-on-exit option to change this behaviour.
-e takes the form โVARIABLE=valueโ and sets an environment variable for the newly created window; it may be specified multiple times.
The TERM environment variable must be set to โscreenโ or โtmuxโ for all programs running inside tmux. New windows will automatically have โTERM=screenโ added to their environment, but care must be taken not to reset this in shell startup files or by the -e option. โ ๏ธ don't sabotage yourself.
The -P option prints information about the new window after it has been created. By default, it uses the format โ#{session_name}:#{window_index}โ but a different format may be specified with -F.
new-pane [-AbCDefhIkKLMOPvWZ] [-B border-lines] [-c start-directory] [-e environment] [-F format] [-l size] [-m message] [-p percentage] [-R inactive-border-style] [-s style] [-S active-border-style] [-t target-pane] [-T title] [-x width] [-y height] [-X x-position] [-Y y-position] [shell-command [argument ...]](alias:newp) โ creates a new floating pane ๐ฆ the iconique floaty ones. The-xand-yoptions set the width and height of the floating pane in columns and lines respectively. The default is half the window width and a quarter the window height. The-Xand-Yoptions set the position of the upper-left corner of the pane. If omitted, new floating panes are cascaded from the top-left of the window. The-x,-y,-X, and-Yoptions may be followed byโ%โto specify a percentage of the window size.-Bsets the pane border lines for floating panes; seepane-border-lines.-Mmay be used when bound to a mouse drag key; the new floating pane is resized to follow the mouse drag.-Acreates a floating pane which remains visible above a zoomed pane.-Ocreates a modal pane. A modal pane is always the active pane and prevents interaction with any other panes while it is active โ main character energy, fr fr ๐. A window can only have one modal pane and it must be a floating pane. With-K, all keys, including the prefix key, are passed directly to the modal pane. With-C, the modal pane is closed when the mouse is clicked outside it. With-D, the modal pane is closed whenโEscapeโorโC-cโis pressed.
The -L option makes new-pane behave like split-window.
All other options have the same meaning as for the split-window command.
next-layout [-t target-window](alias:nextl) โ move a window to the next layout and rearrange the panes to fit. glow up era โจnext-window [-a] [-t target-session](alias:next) โ move to the next window in the session. If-ais used, move to the next window with an alert ๐.pipe-pane [-IOo] [-t target-pane] [shell-command](alias:pipep) โ pipe output sent by the program in target-pane to a shell command or vice versa. A pane may only be connected to one command at a time, so any existing pipe is closed before shell-command is executed. The shell-command string may contain the special character sequences supported by thestatus-leftoption. If no shell-command is given, the current pipe (if any) is closed.
-I and -O specify which of the shell-command output streams are connected to the pane: with -I stdout is connected (so anything shell-command prints is written to the pane as if it were typed); with -O stdin is connected (so any output in the pane is piped to shell-command). Both may be used together and if neither are specified, -O is used.
The -o option only opens a new pipe if no previous pipe exists, allowing a pipe to be toggled with a single key, for example:
bind-key C-p pipe-pane -o 'cat >>~/output.#I-#P'
so handy bestie, iykyk ๐
previous-layout [-t target-window](alias:prevl) โ move to the previous layout in the session.previous-window [-a] [-t target-session](alias:prev) โ move to the previous window in the session. With-a, move to the previous window with an alert.rename-window [-t target-window] new-name(alias:renamew) โ rename the current window, or the window at target-window if specified, to new-name. name it something cute ๐.resize-pane [-MTZ] [-D lines] [-L columns] [-R columns] [-U lines] [-x width] [-y height] [-t target-pane](alias:resizep) โ resize a pane, up, down, left or right by a specified adjustment with-U,-D,-Lor-R; or to an absolute size with-xor-y. The adjustment is given in lines or columns (the default is1);-xand-ymay be a given as a number of lines or columns or followed byโ%โfor a percentage of the window size (for exampleโ-x 10%โ). If target-pane is floating,-U,-D,-L, and-Rtarget their respective borders, and negative values may be given. With-Z, the active pane is toggled between zoomed (occupying the whole of the window) and unzoomed (its normal position in the layout).
-M begins mouse resizing (only valid if bound to a mouse key binding, see โMOUSE SUPPORTโ).
-T trims all lines below the current cursor position and moves lines out of the history to replace them.
resize-window [-aADLRU] [-t target-window] [-x width] [-y height] [adjustment](alias:resizew) โ resize a window, up, down, left or right by adjustment with-U,-D,-Lor-R, or to an absolute size with-xor-y. The adjustment is given in lines or cells (the default is1).-Asets the size of the largest session containing the window;-athe size of the smallest. This command will automatically setwindow-sizetomanualin the window options.respawn-pane [-Ek] [-c start-directory] [-e environment] [-t target-pane] [shell-command [argument ...]](alias:respawnp) โ reactivate a pane in which the command has exited (see theremain-on-exitwindow option). If shell-command is not given, the command used when the pane was created or last respawned is executed. The pane must be already inactive, unless-kis given, in which case any existing command is killed ๐. If-Eis given, the pane is left without a running command.-cspecifies a new working directory for the pane. The-eoption has the same meaning as for thenew-windowcommand.respawn-window [-Ek] [-c start-directory] [-e environment] [-t target-window] [shell-command [argument ...]](alias:respawnw) โ reactivate a window in which the command has exited (see theremain-on-exitwindow option). If shell-command is not given, the command used when the window was created or last respawned is executed. The window must be already inactive, unless-kis given, in which case any existing command is killed. If-Eis given, the window is left with one pane and without a running command.-cspecifies a new working directory for the window. The-eoption has the same meaning as for thenew-windowcommand.rotate-window [-DUZ] [-t target-window](alias:rotatew) โ rotate the positions of the panes within a window, either upward (numerically lower) with-Uor downward (numerically higher).-Zkeeps the window zoomed if it was zoomed. spin spin spin ๐select-layout [-Enop] [-t target-pane] [layout-name](alias:selectl) โ choose a specific layout for a window. If layout-name is not given, the last preset layout used (if any) is reapplied.-nand-pare equivalent to thenext-layoutandprevious-layoutcommands.-oapplies the last set layout if possible (undoes the most recent layout change).-Espreads the current pane and any panes next to it out evenly.select-pane [-DdeLlMmRUZ] [-T title] [-t target-pane](alias:selectp) โ make pane target-pane the active pane in its window. If one of-D,-L,-R, or-Uis used, respectively the pane below, to the left, to the right, or above the target pane is used.-Zkeeps the window zoomed if it was zoomed.-lis the same as using thelast-panecommand.-eenables or-ddisables input to the pane.-Tsets the pane title.
-m and -M are the marked pane girlies โจ โ one sets it, one clears it. There's only one marked pane at a time bestie, so the second you mark a new one the old one gets ๐ cleared, no exceptions. And why do we care? Because the marked pane is the default target for -s on join-pane, move-pane, swap-pane and swap-window. Main character pane behaviour, honestly ๐.
๐ช select-window
select-window [-lnpT] [-t target-window]
(alias: selectw)
Picks the window at target-window ๐. And listen โ -l, -n and -p are literally just the last-window, next-window and previous-window commands wearing a disguise ๐ญ. Then there's -T: if you pass it and the selected window is already the current window, it behaves like last-window instead. Sneaky little toggle, we love her ๐ธ.
โ๏ธ split-window
split-window [-bdefhIkPvZ] [-B border-lines] [-c start-directory] [-e
environment] [-F format] [-l size] [-m message] [-p percentage]
[-R inactive-border-style] [-s style] [-S active-border-style]
[-t target-pane] [-T title] [shell-command [argument ...]]
(alias: splitw)
Okay so this is the icon herself: creates a brand new pane by splitting target-pane ๐.
-dโ the session does not make the new pane the current pane. It gets born but stays in the background, humble queen ๐.-Zโ zooms if the window isn't zoomed, or keeps it zoomed if it already is.-sโ sets the style for the pane content.-Sโ sets the border style when the pane is active.-Rโ sets the border style when the pane is inactive. (Both of these are the "see STYLES" girlies ๐ .)-Tโ sets the pane title.
Then the geometry section, and it matters, so pay attention bestie:
-hdoes a horizontal split and-vdoes a vertical split. If you specify neither?-vis assumed. The default is right there, no cap ๐.-lspecifies the size of the new pane โ in lines for a vertical split, or in columns for a horizontal split. And the size can be followed by โ%โ to mean a percentage of the available space ๐ธ.-pis just shorthand for that percentage thing. Same energy, fewer keystrokes โจ.-Bsets the pane border lines for floating panes โ go readpane-border-linesfor the deets ๐ฆ.-bโ the new pane gets created to the left of or above target-pane. Baby goes first ๐ฅบ.-fโ makes a new pane spanning the full window height (with-h) or the full window width (with-v), instead of just splitting the active pane. Full send ๐.
Now, floating panes get their own lil rules. If target-pane is floating, a new floating pane is created adjacent to it with equal sizes ๐ฏ. The position is decided by the -h, -v, and -b flags. And if any part of the new pane wouldn't be visible on screen, target-pane and the new pane both get resized to fit. Teamwork, fr fr ๐ซถ.
-k keeps the pane open after the optional shell-command exits, and waits for a key press before closing it. The message shown is controlled by the remain-on-exit-format option. And -m message is the same as -k but also sets the remain-on-exit-format option for this pane to message. Two-for-one, iconic ๐.
-W waits until shell-command exits, then returns its exit status. Like so:
$ tmux new-pane -W 'vi afile'
$ echo $?
0
-E โ or just an empty shell-command, ('') โ creates an empty pane with no command running in it. display-message -I can write to an empty pane, iykyk ๐.
-I creates an empty pane and forwards any output from stdin to it. Example time:
$ make 2>&1|tmux new-pane -dI &
๐ swap-pane
swap-pane [-dDUZ] [-s src-pane] [-t dst-pane]
(alias: swapp)
Swaps two panes, periodt ๐.
-Uโ if you use it and don't give a source pane with-s, then dst-pane gets swapped with the previous pane (the one before it numerically).-Dโ swaps with the next pane (the one after it numerically).-dโ tells tmux not to change the active pane, stay put bestie ๐ .-Zโ keeps the window zoomed if it was zoomed.
And the plot twist ๐: if -s is omitted and there's a marked pane hanging around (see select-pane -m), the marked pane is used instead of the current pane. Marked girlies stay winning.
๐ swap-window
swap-window [-d] [-s src-window] [-t dst-window]
(alias: swapw)
Basically link-window's cousin, except the source and destination windows get swapped ๐ซ. It's an error if no window exists at src-window โ like, actual error, not a vibe ๐. And if -d is given, the new window does not become the current window.
Same deal as before: if -s is omitted and there's a marked pane (see select-pane -m), the window containing the marked pane is used rather than the current window ๐ซถ.
โ๏ธ unlink-window
unlink-window [-k] [-t target-window]
(alias: unlinkw)
Unlinks target-window ๐. Here's the rules, listen closely:
- Unless
-kis given, a window may only be unlinked if it is linked to multiple sessions โ windows may not be linked to no sessions, that's not a thing bestie ๐ซ. - If
-kis specified and the window is linked to only one session, it is unlinked and destroyed ๐. Gone. Poof.
๐ KEY BINDINGS ๐
tmux lets a command be bound to most keys, with or without a prefix key โจ. When you're specifying keys, most of them just represent themselves (like โAโ to โZโ, casual). Ctrl keys can be prefixed with โC-โ or โ^โ, Shift keys with โS-โ, and Alt (meta) with โM-โ ๐
. And on top of that, these special key names are accepted: Up, Down, Left, Right, BSpace, BTab, DC (Delete), End, Enter, Escape, F1 to F12, Home, IC (Insert), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space, and Tab.
Okay important note bestie: to bind the โ"โ or โ'โ keys you need quotation marks. Yes really. Like this:
bind-key '"' split-window
bind-key "'" new-window
A command bound to the Any key will execute for all keys which don't have a more specific binding. Catch-all energy, we stan ๐ธ.
Commands related to key bindings are as follows:
๐ bind-key
bind-key [-nr] [-N note] [-T key-table] key [command [argument ...]]
(alias: bind)
Binds key to command ๐. Keys are bound in a key table, and here's the tea:
- By default (no
-T), the key gets bound in the prefix key table. That table is used for keys pressed after the prefix key โ for example, by default โcโ is bound tonew-windowin the prefix table, so โC-b cโ creates a new window ๐. - The root table is for keys pressed without the prefix key. Binding โcโ to
new-windowin the root table (โ ๏ธ not recommended bestie) means a plain โcโ creates a new window. Chaos. - Keys can also be bound in custom key tables, and the
switch-client -Tcommand is how you switch to them from a key binding ๐ฆ. -rโ indicates this key may repeat. See theinitial-repeat-timeandrepeat-timeoptions โญ.-Nโ attaches a note to the key (shown withlist-keys -N), and you clear it by passing an empty string.- The
-rand-Nflags can both be used without command to alter an existing binding ๐
To view the default bindings and possible commands, go see the list-keys command ๐ซถ.
๐ list-keys
list-keys [-1aNr] [-F format] [-O sort-order] [-P prefix-string] [-T
key-table] [key]
(alias: lsk)
Lists key bindings โจ.
-Fโ specifies the format of each line. See the โFORMATSโ section ๐.-Tโ specifies a key-table to list from.-1โ lists only the first matching key.-Oโ specifies the sort order: one of โkeyโ, โmodifierโ, โnameโ (that's the table name).-rโ reverses the sort order ๐.
If no format is given, there are two forms, bestie:
- The default lists keys as
bind-keycommands. -Nlists only keys with attached notes, and shows only the key and note for each key ๐.
With the default form, all key tables are listed unless specified otherwise. With the -N form, only keys in the root and prefix key tables are listed by default; -T also lists only keys in key-table. -P specifies a prefix to print before each key ๐. And -a lists the command for keys that don't have a note rather than skipping them. No key left behind ๐
.
๐จ send-keys
send-keys [-FHKlMRX] [-c target-client] [-N repeat-count] [-t
target-pane] [key ...]
(alias: send)
Sends a key or keys to a window or client ๐ฌ. Each argument key is the name of the key (like โC-aโ or โNPageโ) to send; and if the string isn't recognised as a key, it gets sent as a series of characters. Fine, we improvise ๐.
-Kโ keys are sent to target-client instead, so they're looked up in the client's key table rather than in target-pane.
All arguments are sent sequentially, first to last, in order, no jumping the queue ๐ค. And if no keys are given and the command is bound to a key, then that key is used. Self-referential, iconic.
-lโ disables key name lookup and processes the keys as literal UTF-8 characters ๐ฆ.-Hโ expects each key to be a hexadecimal number for an ASCII character ๐ข.-Rโ causes the terminal state to be reset ๐.-Mโ passes through a mouse event (only valid if bound to a mouse key binding, see โMOUSE SUPPORTโ) ๐ญ.-Xโ sends a command into copy mode, see the โWINDOWS AND PANESโ section ๐.-Nโ specifies a repeat count.-Fโ expands formats in arguments where appropriate โจ.
๐ฏ send-prefix
send-prefix [-2] [-t target-pane]
Sends the prefix key to a window as if it was pressed ๐น โ or with -2, the secondary prefix key. Yes, there's a second one. She has layers ๐
.
๐ unbind-key
unbind-key [-anq] [-T key-table] key
(alias: unbind)
Unbinds the command bound to key ๐. -n and -T work the same as they do for bind-key. If -a is present, all key bindings are removed โ every single one, scorched earth, no survivors ๐. The -q option prevents errors being returned, so it just vibes quietly instead ๐คซ.
โจ OPTIONS โจ
The appearance and behaviour of tmux can be modified by changing the value of various options ๐. Each option belongs to one or multiple scopes (server, session, window, and pane) and has a type (string, number, key, colour, flag, choice, or command) ๐.
Values of flag-type options may be one of: 1, on, yes, 0, off, or no ๐ข๐ด. For possible choice values, see the respective option; for key options, check the โKEY BINDINGSโ section; and for colour options, the โSTYLESโ section ๐จ.
The tmux server has a set of global server options which do not apply to any particular window or session or pane ๐. These are altered with the set-option -s command, or displayed with the show-options -s command โจ.
On top of that, each individual session may have a set of session options, and there is a separate set of global session options ๐ธ. Sessions which don't have a particular option configured inherit the value from the global session options โ the family heirloom vibe ๐ซถ. Session options are set or unset with the set-option command and may be listed with the show-options command. The available server and session options are listed under the set-option command ๐.
Similarly, a set of window options is attached to each window ๐ช and a set of pane options to each pane. Pane options inherit from window options โ the vibes trickle down, bestie, it's a whole family tree. This means any pane option may be set as a window option to apply the option to all panes in the window without the option set, for example these commands will set the background colour to red for all panes except pane 0:
set -w window-style bg=red
set -pt:.0 window-style bg=blue
There is also a set of global window options from which any unset window or pane options are inherited. Window and pane options are altered with set-option -w and -p commands and displayed with show-option -w and -p.
tmux also supports user options which are prefixed with a @. User options may have any name, so long as they are prefixed with @, and be set to any string, no cap. For example:
$ tmux set -wq @foo "abc123"
$ tmux show -wv @foo
abc123
Options are managed with these commands:
๐
set-option
set-option [-aFgopqsuUw] [-t target-pane] option [value]
(alias: set)
Set a pane option with -p, a window option with -w, a server option with -s, otherwise a session option. If the option is not a user option, -w or -s may be unnecessary โ tmux will infer the scope from the option name, assuming -w for pane options. If -g is given, the global session or window option is set.
Array options may be set by giving a key in square brackets after the option name, for example command-alias[zoom].
Here's the flag rundown, so nothing slips past you:
-Fโ expands formats in the option value.-uโ unsets an option, so a session inherits the option from the global options (or with-g, restores a global option to the default).-Uโ unsets an option (like-u) but if the option is a pane option also unsets the option on any panes in the window.-oโ prevents setting an option that is already set.-qโ suppresses errors about unknown or ambiguous options.-aโ append mode, see below.
value depends on the option and its type and can be omitted for flag and choice options to toggle its value (choice options toggle between the first two choices).
With -a, and if the option expects a string or a style, value is appended to the existing setting. For example:
set -g status-left "foo"
set -ag status-left "bar"
Will result in foobar. And:
set -g status-style "bg=red"
set -ag status-style "fg=blue"
Will result in a red background and blue foreground. Without -a, the result would be the default background and a blue foreground. ๐จ
๐ซถ show-options
show-options [-AgHpqsvw] [-F format] [-t target-pane] [option]
(alias: show)
Show the pane options (or a single option if option is provided) with -p, the window options with -w, the server options with -s, otherwise the session options. If the option is not a user option, -w or -s may be unnecessary โ tmux will infer the scope from the option name, assuming -w for pane options. Global session or window options are listed if -g is used.
-vโ shows only the option value, not the name. Just the tea, no label. ๐ต-Fโ format is used for each option.-qโ no error will be returned if option is unset.-Hโ includes hooks (omitted by default).-Aโ includes options inherited from a parent set of options; such options are marked with an asterisk.
โจ Available server options are โจ
backspace key
Set the key sent by tmux for backspace.
buffer-limit number
Set the number of buffers; as new buffers are added to the top of the stack, old ones are removed from the bottom if necessary to maintain this maximum length. ๐
clear-on-attach [on | off]
When enabled (the default), the client terminal switches to the alternate screen and clears it when a client is attached. When disabled, tmux does not enter the alternate screen; instead the existing terminal content is scrolled into the scrollback buffer so it remains accessible.
command-alias[] name=value
This is an array of custom aliases for commands. If an unknown command matches name, it is replaced with value. For example, after:
set -s command-alias[zoom] zoom='resize-pane -Z'
Using:
zoom -t:.1
Is equivalent to:
resize-pane -Z -t:.1
Note that aliases are expanded when a command is parsed rather than when it is executed, so binding an alias with bind-key will bind the expanded form. ๐
codepoint-widths[] string
An array option allowing widths of Unicode codepoints to be overridden. Note the new width applies to all clients. Each entry is of the form codepoint=width, where codepoint may be a UTF-8 character, an identifier of the form U+number where the number is a hexadecimal number, or a range of the form U+number-U+number.
copy-command shell-command
Give the command to pipe to if the copy-pipe copy mode command is used without arguments.
theme [detect | terminal | light | dark]
Whether tmux should use the detected client theme (detect), use terminal ANSI colours (terminal), or force the light or dark theme.
dark-theme-black, dark-theme-white, dark-theme-light-grey, dark-theme-dark-grey, dark-theme-green, dark-theme-yellow, dark-theme-red, dark-theme-blue, dark-theme-cyan, dark-theme-magenta, light-theme-black, light-theme-white, light-theme-light-grey, light-theme-dark-grey, light-theme-green, light-theme-yellow, light-theme-red, light-theme-blue, light-theme-cyan and light-theme-magenta colour
Set the theme colours. These are the named colours themeblack, themewhite, themelightgrey, themedarkgrey, themegreen, themeyellow, themered, themeblue, themecyan and thememagenta which may be used in styles and elsewhere a colour is accepted. The dark-theme-* set is used when the client reports a dark background and the light-theme-* set when it reports a light background; an unknown background is treated as dark. ๐
default-client-command command
Set the default command to run when tmux is called without a command. The default is new-session.
default-terminal terminal
Set the default terminal for new windows created in this session โ the default value of the TERM environment variable. For tmux to work correctly, this must be set to screen, tmux or a derivative of them.
escape-time time
Set the time in milliseconds for which tmux waits after an escape is input to determine if it is part of a function or meta key sequences.
editor shell-command
Set the command used when tmux runs an editor.
exit-empty [on | off]
If enabled (the default), the server will exit when there are no active sessions.
exit-unattached [on | off]
If enabled, the server will exit when there are no attached clients.
extended-keys [on | off | always]
Controls how modified keys (keys pressed together with Control, Meta, or Shift) are reported. This is the equivalent of the modifyOtherKeys xterm(1) resource.
When set to on, the program inside the pane can request one of two modes: mode 1 which changes the sequence for only keys which lack an existing well-known representation; or mode 2 which changes the sequence for all keys. When set to always, modes 1 and 2 can still be requested by applications, but mode 1 will be forced instead of the standard mode. When set to off, this feature is disabled and only standard keys are reported.
tmux will always request extended keys itself if the terminal supports them. See also the extkeys feature for the terminal-features option, the extended-keys-format option and the pane_key_mode variable.
extended-keys-format [csi-u | xterm]
Selects one of the two possible formats for reporting modified keys to applications. This is the equivalent of the formatOtherKeys xterm(1) resource. For example, C-S-a will be reported as ^[[27;6;65~ when set to xterm, and as ^[[65;6u when set to csi-u. โจ๏ธ
focus-events [on | off]
When enabled, focus events are requested from the terminal if supported and passed through to applications running in tmux. Attached clients should be detached and attached again after changing this option.
focus-follows-mouse [on | off]
When enabled and mouse is on, moving the mouse into a pane selects it.
get-clipboard [both | request | buffer | off]
Controls the behaviour when an application requests the clipboard from tmux.
If off, the request is ignored; if buffer, tmux responds with the newest paste buffer; request causes tmux to request the clipboard from the most recently used client (if possible) and send the reply (if any) back to the application; both is the same as request but also creates a paste buffer.
See also the set-clipboard option. ๐
history-file path
If not empty, a file to which tmux will write command prompt history on exit and load it from on start.
input-buffer-size bytes
Maximum of bytes allowed to read in escape and control sequences. Once reached, the sequence will be discarded.
message-limit number
Set the number of error or information messages to save in the message log for each client.
prompt-history-limit number
Set the number of history items to save in the history file for each type of command prompt.
set-clipboard [on | external | off]
Attempt to set the terminal clipboard content using the xterm(1) escape sequence, if there is an Ms entry in the terminfo(5) description (see the โTERMINFO EXTENSIONSโ section).
If it's set to on, tmux will โจbothโจ accept the escape sequence that creates a buffer and try to set the terminal clipboard. If it's set to external, tmux tries to set the terminal clipboard but ignores any attempts by applications to set tmux buffers. And if it's off? tmux neither accepts the clipboard escape sequence nor tries to touch the clipboard at all. ๐
Heads up bestie โ this whole feature has to be enabled in xterm(1) first by setting the resource:
disallowedWindowOps: 20,21,SetXprop
Or by changing that property from the xterm(1) interactive menu whenever you need it. ๐
๐ terminal-features[] string
Set terminal features for terminal types read from terminfo(5). tmux has a whole set of named terminal features, and each one applies the appropriate changes to the terminfo(5) entry in use. ๐ฆ
tmux can detect features for a few common terminals, and this option is how you easily tell tmux about features supported by terminals it can't detect. The terminal-overrides option lets you set individual terminfo(5) capabilities instead โ terminal-features is meant for classes of functionality supported in a standard way but just not reported by terminfo(5). Careful out here: only configure this with features the terminal actually supports, fr fr. ๐
This is an array option where each entry is a colon-separated string made up of a terminal type pattern (matched using glob(7) patterns) followed by a list of terminal features. A feature may be suffixed with @ to disable it; for example, xterm*:sync@. The available features are:
256โ Supports 256 colours with the SGR escape sequences.appescโ Supports application escape key mode, where the Escape key sends a sequence that cannot be mistaken for the start of another key.clipboardโ Allows setting the system clipboard.ccolourโ Allows setting the cursor colour.cstyleโ Allows setting the cursor style.extkeysโ Supports extended keys.focusโ Supports focus reporting.hyperlinksโ Supports OSC 8 hyperlinks.ignorefkeysโ Ignore function keys fromterminfo(5)and use the tmux internal set only.marginsโ Supports DECSLRM margins.mouseโ Supportsxterm(1)mouse sequences.osc7โ Supports the OSC 7 working directory extension.overlineโ Supports the overline SGR attribute.progressbarโ Supports the OSC 9;4 progress bar extension.rectfillโ Supports the DECFRA rectangle fill escape sequence.RGBโ Supports RGB colour with the SGR escape sequences.sixelโ Supports SIXEL graphics.strikethroughโ Supports the strikethrough SGR escape sequence.syncโ Supports synchronized updates.titleโ Supportsxterm(1)title setting.usstyleโ Allows underscore style and colour to be set.utf8โ Supports UTF-8 output.
๐ terminal-overrides[] string
Allow terminal descriptions read using terminfo(5) to be overridden. Each entry is a colon-separated string made up of a terminal type pattern (matched using glob(7) patterns) and a set of name=value entries. ๐
So like, say you wanna set the clear terminfo(5) entry to \e[H\e[2J for all terminal types matching rxvt*:
rxvt*:clear=\e[H\e[2J
The terminal entry value gets passed through strunvis(3) before interpretation. โญ
๐ธ user-keys[] key
Set list of user-defined key escape sequences. Each item is associated with a key named User0, User1, and so on. Obsessed with this one ngl.
For example:
set -s user-keys[0] "\e[5;30012~"
bind User0 resize-pane -L 3
๐ variation-selector-always-wide [on | off]
Always treat Unicode variation selector 16 as marking a wide character. This is a feature of some terminals as part of their Unicode 14 support. ๐ง
๐ Available session options are:
activity-action [any | none | current | other]
Set action on window activity when monitor-activity is on. any means activity in any window linked to a session causes a bell or message (depending on visual-activity) in the current window of that session, none means all activity is ignored (equivalent to monitor-activity being off), current means only activity in windows other than the current window are ignored, and other means activity in the current window is ignored but not those in other windows. ๐
assume-paste-time milliseconds
If keys are entered faster than one in milliseconds, they are assumed to have been pasted rather than typed and tmux key bindings are not processed. The default is one millisecond and zero disables. โฑ๏ธ
base-index index
Set the base index from which an unused index should be searched when a new window is created. The default is zero.
bell-action [any | none | current | other]
Set action on a bell in a window when monitor-bell is on. The values are the same as those for activity-action. ๐
default-command shell-command
Set the command used for new windows (if not specified when the window is created) to shell-command, which may be any sh(1) command. The default is an empty string, which instructs tmux to create a login shell using the value of the default-shell option.
default-shell path
Specify the default shell. This is used as the login shell for new windows when the default-command option is set to empty, and must be the full path of the executable. When started tmux tries to set a default value from the first suitable of the SHELL environment variable, the shell returned by getpwuid(3), or /bin/sh. This option should be configured when tmux is used as a login shell. ๐ซถ
default-size XxY
Set the default size of new windows when the window-size option is set to manual or when a session is created with new-session -d. The value is the width and height separated by an x character. The default is 80x24.
destroy-unattached [off | on | keep-last | keep-group]
If on, destroy the session after the last client has detached. If off (the default), leave the session orphaned. If keep-last, destroy the session only if it is in a group and has other sessions in that group. If keep-group, destroy the session unless it is in a group and is the only session in that group. ๐
detach-on-destroy [off | on | no-detached | previous | next]
If on (the default), the client is detached when the session it is attached to is destroyed. If off, the client is switched to the most recently active of the remaining sessions. If no-detached, the client is detached only if there are no detached sessions; if detached sessions exist, the client is switched to the most recently active. If previous or next, the client is switched to the previous or next session in alphabetical order. ๐ฅ
display-time time
Set the amount of time for which status line messages and other on-screen indicators are displayed. If set to 0, messages and indicators are displayed until a key is pressed. time is in milliseconds.
history-limit lines
Set the maximum number of lines held in pane history. ๐
initial-repeat-time time
Set the time in milliseconds for the initial repeat when a key is bound with the -r flag. This allows multiple commands to be entered without pressing the prefix key again. See also the repeat-time option. If initial-repeat-time is zero, repeat-time is used for the first key press.
key-table key-table
Set the default key table to key-table instead of root.
lock-after-time number
Lock the session (like the lock-session command) after number seconds of inactivity. The default is not to lock (set to 0). ๐
lock-command shell-command
Command to run when locking each client. The default is to run lock(1) with -np.
menu-style style
Set the menu style. See the โSTYLESโ section on how to specify style.
menu-selected-style style
Set the selected menu item style. See the โSTYLESโ section on how to specify style.
menu-border-style style
Set the menu border style. See the โSTYLESโ section on how to specify style.
menu-border-lines type
Set the type of characters used for drawing menu borders. See popup-border-lines for possible values for border-lines.
message-command-style style
Set status line message command style. This is used for the command prompt with vi(1) keys when in command mode. For how to specify style, see the โSTYLESโ section.
message-format string
Set the format string for the prompt and message area. The special placeholder #{message} expands to the interactive prompt or message text and #{command_prompt} is set to 1 when the prompt is in command mode (vi). Style directives like fill, align, and width may be used in the format string. The default uses a conditional to select between message-style and message-command-style. โจ
message-line [0 | 1 | 2 | 3 | 4]
Set line on which status line messages and the command prompt are shown.
message-stylestyle โ sets the style of status line messages. This one covers messages and the command prompt, and the message gets drawn right on top of whatever status line is already there. A width attribute (either a fixed number of columns or a percentage like50%) limits how wide the prompt area is, and an align attribute (left,centre,right) decides where it sits horizontally. If that width is smaller than the full terminal width, the normal status bar content stays visible around the prompt area, cute right? The fill attribute is what the default message-format uses to clear the background. Wanna know how to write a style? Go peek at STYLES ๐mouse[on|off] โ set itonand tmux captures the mouse, meaning mouse events can be bound as key bindings. Deets live in MOUSE SUPPORT ๐ญprefixkey โ sets the key that counts as the prefix key. On top of the standard keys listed under KEY BINDINGS, you can also set this to the special keyNoneif you want, like, no prefix at all ๐prefix2key โ sets a secondary key that also works as a prefix key. Same deal asprefix:Noneis allowed.prefix-timeouttime โ how many milliseconds tmux waits after you hit the prefix before it just gives up and dismisses it. Set it to zero and the timeout is fully disabled, no cap.prompt-cursor-colourcolour โ the colour of the cursor inside the command prompt.prompt-command-cursor-colourcolour โ the colour of the cursor in the command prompt specifically when vi(1) keys are enabled and the prompt is chillin' in command mode.prompt-cursor-stylestyle โ the style of the cursor in the command prompt. Available styles? Check the cursor-style options, bestie.prompt-command-cursor-stylestyle โ same thing but for when vi(1) keys are on and the prompt is in command mode. Again, see the cursor-style options for what styles exist.renumber-windows[on|off] โ turn thisonand whenever a window closes in a session, the other windows get automatically renumbered in numerical order. It respects thebase-indexoption if you've set one.offmeans no renumbering, leave them alone ๐repeat-timetime โ lets you fire off multiple commands without smashing the prefix key again, within the given number of milliseconds (default is500, iconic). Whether a key actually repeats is decided when it's bound, using the-rflag tobind-key. Repeat is enabled for the default keys bound to theresize-panecommand. Also see theinitial-repeat-timeoption โจset-titles[on|off] โ attempts to set the client terminal title using thetslandfslterminfo(5) entries, if those exist. tmux automatically sets these to the\e]0;...\007sequence if the terminal looks like it's xterm(1). Heads up: this option isoffby default.set-titles-stringstring โ the string used to set the client terminal title whenset-titlesis on. Formats get expanded, check FORMATS ๐silence-action[any|none|current|other] โ picks the action for window silence whenmonitor-silenceis on. The values are the exact same ones as foractivity-action.status[off|on|2|3|4|5] โ show or hide the status line, or say how big it is.ongives you a status line one row tall;2,3,4or5give you more rows.status-format[]format โ the format used for each line of the status line. The default builds the top status line out of all those individual status options listed below โจstatus-intervalinterval โ refresh the status line every interval seconds. Default behaviour is an update every 15 seconds. Set it to zero and redrawing at an interval is disabled entirely.status-justify[left|centre|right|absolute-centre] โ where the window list sits in the status line:left,centreorright.centreputs the window list in the relative centre of whatever free space exists;absolute-centreuses the centre of the entire horizontal space. Subtle difference, but it matters ๐status-keys[vi|emacs] โ picks vi or emacs-style key bindings for the status line, like at the command prompt. Default isemacs, unlessVISUALorEDITORenvironment variables are set and contain the stringvi.status-leftstring โ the display string (by default the session name) shown to the left of the status line. The string gets passed through strftime(3). Also go read FORMATS and STYLES. For details on setting names and titles, see NAMES AND TITLES.
Some examples, bestie:
#(sysctl vm.loadavg)
#[fg=yellow,bold]#(apm -l)%%#[default] [#S]
And the default is [#S] .
status-left-lengthlength โ the max length of the left component of the status line. Default is10.status-left-stylestyle โ the style of the left part of the status line. For how to write a style, see STYLES.status-position[top|bottom] โ where the status line lives.status-rightstring โ the display string to the right of the status line. By default it shows the current pane title in double quotes, plus the date and the time. Just likestatus-left, the string gets passed to strftime(3) and character pairs get replaced.status-right-lengthlength โ the max length of the right component of the status line. Default is40.status-right-stylestyle โ the style of the right part of the status line. Again, STYLES section for the how-to.status-stylestyle โ the style for the status line. You already know where to look: STYLES ๐update-environment[]variable โ the list of environment variables that get copied into the session environment whenever a new session is created or an existing one is attached. Any variables that don't exist in the source environment are marked to be removed from the session environment โ as if-rwas passed to theset-environmentcommand.visual-activity[on|off|both] โ ifon, tmux shows a message instead of sending a bell when activity happens in a window that has themonitor-activitywindow option enabled. Set it tobothand you get a bell and a message. Double trouble ๐visual-bell[on|off|both] โ ifon, a message pops up on a bell in a window that has themonitor-bellwindow option enabled, instead of it being passed through to the terminal (which is what normally makes the actual sound).bothgives you the bell and the message. Also see thebell-actionoption.visual-silence[on|off|both] โ ifmonitor-silenceis enabled, this prints a message after the interval has expired on a given window, instead of firing off a bell.bothmeans a bell and a message, obviously ๐word-separatorsstring โ sets what the session thinks counts as word separator characters, for the sake of the next and previous word commands in copy mode. A space in string matches any character with the Unicode White_Space property.
Available window options are: ๐
aggressive-resize[on|off] โ aggressively resize the chosen window. Meaning tmux resizes the window to the size of the smallest or largest session (see thewindow-sizeoption) for which it's the current window, instead of the session it's attached to. The window can resize when the current window changes on another session. This option is great for full-screen programs that support SIGWINCH, and honestly terrible for interactive stuff like shells. Pick your fighter ๐automatic-rename[on|off] โ controls automatic window renaming. With this on, tmux renames the window automatically using the format given byautomatic-rename-format. This flag gets automatically disabled for an individual window when a name is specified at creation withnew-windowornew-session, or later withrename-window, or with a terminal escape sequence. You can also switch it off globally with:
set-option -wg automatic-rename off
automatic-rename-formatformat โ the format (see FORMATS) used when theautomatic-renameoption is enabled.clock-mode-colourcolour โ sets the clock colour ๐ฐ๏ธclock-mode-style[12|24|12-with-seconds|24-with-seconds] โ sets the clock's hour format.display-panes-active-colourcolour โ the colour thedisplay-panescommand uses to show the indicator for the active pane.display-panes-border-stylestyle โ the style of the borders in panes mode used by thedisplay-panescommand. Style how-to is in STYLES.display-panes-colourcolour โ the colour thedisplay-panescommand uses to show the indicators for the inactive panes.display-panes-formatformat โ the format of the text shown by thedisplay-panescommand, expanded once for each pane.display-panes-timetime โ how many milliseconds the indicators shown by thedisplay-panescommand hang around for.fill-characterformat โ the format used to fill terminal areas that a pane isn't using. It's expanded once for areas inside the window withis_insideset, and once for areas outside the window withis_outsideset.main-pane-heightheight โ and alsomain-pane-widthwidth โ set the width or height of the main (left or top) pane in themain-horizontal,main-horizontal-mirrored,main-verticalormain-vertical-mirroredlayouts. Suffix it with%and it becomes a percentage of the window size โจcopy-mode-match-stylestyle โ the style of search matches in copy mode. STYLES section, as always ๐ซถcopy-mode-mark-stylestyle โ the style of the line containing the mark in copy mode. Yep, STYLES ๐copy-mode-current-match-stylestyle โ sets the glow-up for the current search match when you're in copy mode โจ. Wanna know how to build a style? Check the โSTYLESโ section bestie ๐copy-mode-position-formatformat โ the format of that lil position indicator in copy mode ๐copy-mode-position-stylestyle โ style for the position indicator in copy mode ๐ (STYLES section has the deets on specifying style)copy-mode-selection-stylestyle โ style for your selection in copy mode ๐ (again, โSTYLESโ section, you know the drill)copy-mode-current-line-number-stylestyle โ style for the current line number in copy mode ๐ (โSTYLESโ section!)copy-mode-current-line-stylestyle โ style for the line the cursor is chillin' on in copy mode ๐ (โSTYLESโ section)copy-mode-line-number-stylestyle โ style for all the line numbers in copy mode ๐ข (โSTYLESโ section, mwah)copy-mode-line-numbers[off|default|absolute|relative|hybrid] โ show line numbers in copy mode, fr fr. Let's break it down:offโ hides them, bye ๐defaultโ shows line numbers matching the copy mode position indicator andgoto-lineabsoluteโ shows absolute line numbersrelativeโ shows line numbers relative to the cursorhybridโ shows the current line number as absolute, and every other line number as relative โจ
With off or default, the position indicator and goto-line use the same numbering. With absolute, relative and hybrid, they use absolute line numbers. Noted ๐
mode-keys[vi|emacs] โ use vi or emacs-style key bindings in copy mode ๐น. Default isemacs, unlessVISUALorEDITORcontains โviโ (then you're a vi girlie, iykyk)mode-stylestyle โ sets the window modes style. โSTYLESโ section for how, bestie ๐monitor-activity[on|off] โ monitor for activity in the window ๐. Windows with activity get highlighted in the status line, slaymonitor-bell[on|off] โ monitor for a bell ๐ in the window. Windows with a bell get highlighted in the status linemonitor-silence[interval] โ monitor for silence (aka no activity) in the window within interval seconds ๐คซ. Windows that have been silent for the interval get highlighted in the status line. An interval of zero disables the monitoring, periodtother-pane-heightheight โ sets the height of the other panes (not the main pane) in themain-horizontalandmain-horizontal-mirroredlayouts ๐. If this is set to0(the default), it has no effect, so it's giving nothing. If bothmain-pane-heightandother-pane-heightare set, the main pane grows taller to make the other panes the specified height โ but it will never shrink to do so. If suffixed by โ%โ, this is a percentage of the window size ๐ฏother-pane-widthwidth โ likeother-pane-height, but it sets the width of other panes in themain-verticalandmain-vertical-mirroredlayouts ๐pane-active-border-stylestyle โ sets the pane border style for the currently active pane ๐. โSTYLESโ section for how. Heads up: attributes are ignored ๐pane-base-indexindex โ likebase-index, but for the starting index of pane numbers ๐ขpane-border-formatformat โ sets the text shown in pane border status lines โ๏ธpane-border-indicators[off|colour|arrows|both] โ indicate the active pane by colouring only half of the border (but only in windows with exactly two panes!), by displaying arrow markers, by drawing both, or by drawing neither ๐ฏpane-border-linestype โ sets the type of characters used for drawing pane borders. type can be one of:singleโ single lines using ACS or UTF-8 charactersdoubleโ double lines using UTF-8 charactersheavyโ heavy lines using UTF-8 characterssimpleโ simple ASCII charactersnumberโ the pane numberspacesโ space charactersnoneโ no border for floating panes
โdoubleโ and โheavyโ will fall back to standard ACS line drawing when UTF-8 is not supported ๐ซถ
pane-border-status[off|top|bottom|top-floating|bottom-floating] โ turn pane border status lines off, or set their position ๐. If set totop-floatingorbottom-floating, status lines are shown only on floating panes ๐ชpane-border-stylestyle โ sets the pane border style for panes aside from the active one โจ. โSTYLESโ section for how. Attributes? Ignored, bestie ๐popup-stylestyle โ sets the popup style ๐. See the โSTYLESโ section on how to specify style. Attributes are ignoredpopup-border-stylestyle โ sets the popup border style ๐ . See the โSTYLESโ section on how to specify style. Attributes are ignoredpopup-border-linestype โ sets the type of characters used for drawing popup borders. type can be one of:singleโ single lines using ACS or UTF-8 characters (default)roundedโ a variation of single with rounded corners using UTF-8 characters ๐ซงdoubleโ double lines using UTF-8 charactersheavyโ heavy lines using UTF-8 characterssimpleโ simple ASCII characterspaddedโ simple ASCII space characternoneโ no border
โdoubleโ and โheavyโ will fall back to standard ACS line drawing when UTF-8 is not supported ๐ธ
pane-scrollbars[off|modal|on|auto-hide] โ when enabled, a character based scrollbar appears on the left or right of each pane ๐. A filled section of the scrollbar, known as the โsliderโ, represents the position and size of the visible part of the pane content ๐
If set to on the scrollbar is visible all the time and the pane is narrowed by the width of the scrollbar. If set to modal the scrollbar only appears when the pane is in copy mode or view mode, and auto-hides when not in use. If set to auto-hide the scrollbar is available all the time but auto-hides when not in use. With modal and auto-hide, the scrollbar overlays the pane and does not narrow or reflow it, iconic โจ
See also pane-scrollbars-style.
pane-scrollbars-position[left|right] โ sets which side of the pane to display pane scrollbars on โฌ ๏ธโก๏ธpane-scrollbars-stylestyle โ sets the scrollbars style ๐จ. โSTYLESโ section for how. The foreground colour is used for the slider, the background for the rest of the scrollbar. Thewidthattribute sets the width of the scrollbar, and thepadattribute sets the padding between the scrollbar and the pane. Other attributes are ignored ๐pane-scrollbars-timeouttime โ sets the time in milliseconds before scrollbars are hidden whenpane-scrollbarsismodalorauto-hideโฑ๏ธpane-status-current-stylestyle โ sets the status line style for the currently active pane ๐. โSTYLESโ section for howpane-status-stylestyle โ sets the status line style for a single pane ๐. โSTYLESโ section for howsession-status-current-stylestyle โ sets the status line style for the currently active session ๐. โSTYLESโ section for howsession-status-stylestyle โ sets the status line style for a single session ๐ฆ. โSTYLESโ section for howtiled-layout-max-columnsnumber โ sets the maximum number of columns in the tiled layout ๐งฑ. A value of0(the default) means no limit. When a limit is set, panes are arranged to not exceed this number of columns, with additional panes stacked in extra rows ๐ฅtree-mode-border-stylestyle โ sets the style of borders in tree mode ๐ณ. โSTYLESโ section for howtree-mode-preview-formatformat โ the format of the preview indicator in tree mode ๐๏ธtree-mode-preview-stylestyle โ sets the style of the preview indicator in tree mode โจ. โSTYLESโ section for howtree-mode-selection-stylestyle โ sets the style of the selected line in tree mode ๐. โSTYLESโ section for howwindow-status-activity-stylestyle โ sets the status line style for windows with an activity alert ๐จ. โSTYLESโ section for howwindow-status-bell-stylestyle โ sets the status line style for windows with a bell alert ๐. โSTYLESโ section for howwindow-status-current-formatstring โ likewindow-status-format, but this is the format used when the window is the current window ๐window-status-current-stylestyle โ sets the status line style for the currently active window ๐. โSTYLESโ section for howwindow-status-formatstring โ sets the format in which the window is displayed in the status line window list ๐ช. See the โFORMATSโ and โSTYLESโ sectionswindow-status-last-stylestyle โ sets the status line style for the last active window โฎ๏ธ. โSTYLESโ section for howwindow-status-separatorstring โ sets the separator drawn between windows in the status line โ. The default is a single space characterwindow-status-stylestyle โ sets the status line style for a single window ๐. โSTYLESโ section for howwindow-sizelargest|smallest|manual|latestโ configure how tmux determines the window size ๐:largestโ the size of the largest attached session is usedsmallestโ the size of the smallestmanualโ the size of a new window is set from thedefault-sizeoption, and windows are resized automaticallylatestโ tmux uses the size of the client that had the most recent activity
See also the resize-window command and the aggressive-resize option ๐
wrap-search[on|off] โ if this option is set, searches will wrap around the end of the pane contents ๐. The default ison
Available pane options are: ๐ซถ
allow-passthrough [on | off | all]โ bestie, this one lets programs running inside a pane straight-up bypass tmux using a terminal escape sequence (\ePtmux;...\e\\). Set it toonand those passthrough sequences are only allowed if the pane is actually visible ๐. Set it toalland they get let through even when the pane is invisible. Lowkey powerful, highkey chaotic ๐allow-rename [on | off]โ gives programs in the pane permission to rename the window using a terminal escape sequence (\ek...\e\\). Window names, but make it โจcollaborativeโจ.allow-set-title [on | off]โ lets programs in the pane change the title via terminal escape sequences (\e]2;...\e\\or\e]0;...\e\\). That's it, that's the whole vibe ๐alternate-screen [on | off]โ controls whether programs inside the pane get to use the terminal's alternate screen feature, aka thesmcupandrmcupterminfo(5)capabilities ๐. Why do you care? Because the alternate screen feature preserves the contents of the window when an interactive app starts and restores it when it exits โ so everything you could see before the app launched reappears completely unchanged once it's gone. It's giving "no notes, we saved your screen" ๐ธcursor-colour colourโ sets the colour of the cursor. Your cursor, your aesthetic, periodt ๐cursor-style styleโ sets the style of the cursor. The available styles are:default,blinking-block,block,blinking-underline,underline,blinking-bar,bar. Pick your fighter, she's serving cursor ๐pane-colours[] colourโ the default colour palette. Every single entry in this array defines which colour tmux actually uses when the colour with that index gets requested. The index can run anywhere from zero to 255. So if a program asks for colour number 42,pane-colours[42]is what it's gonna get ๐remain-on-exit [on | off | failed | key | failed-key]โ a pane with this flag set does not get destroyed when the program running in it exits. Immortal pane behavior ๐. Break it down:failedโ only keeps it around when the program's exit status is not zero.keyโ the pane stays open and then closes when a key is pressed.failed-keyโ the pane stays open and closes when a key is pressed, but only if the program's exit status is not zero.
And whenever a pane's just chillin' there like this, you can bring it back to life with the respawn-pane command ๐ฆ
remain-on-exit-format stringโ sets the text shown at the bottom of exited panes whenremain-on-exitis enabled. That little goodbye note ๐ฅบscroll-on-clear [on | off]โ when the entire screen gets cleared and this option is on, tmux scrolls the contents of the screen into history before wiping it. So nothing is ever really lost, it just moved to a better neighborhood โจswitch-mode-match-style styleโ sets the style of the characters matched by the filter in switch-mode. Wanna know how to specify a style? Go look at the โSTYLESโ section, go go go ๐โโ๏ธsynchronize-panes [on | off]โ duplicates your input to all the other panes in the same window where this option is also on. Only for panes that aren't in any mode, bestie. Type once, echo everywhere ๐ฅwindow-active-style styleโ sets the pane style for when it is the active pane. Same deal for specifying it: check the โSTYLESโ section ๐window-style styleโ sets the pane style. And yes, โSTYLESโ section, always the โSTYLESโ section ๐window-pane-status-format stringโ sets the format that the window pane is displayed in, inside the status line window pane list. See the โFORMATSโ and โSTYLESโ sections ๐window-pane-current-status-format stringโ likewindow-status-format, but this is the format used when the window is the current window. The main character gets her own outfit ๐
๐ช HOOKS ๐ช
Okay so tmux lets commands run on all sorts of triggers, and those triggers are called hooks. Most tmux commands have an after hook, and on top of that there's a whole bunch of hooks that aren't attached to any command at all ๐
Hooks live as array options โ the members of that array get executed in order when the hook fires. And just like options, different hooks can be global or belong to a session, a window, or a pane. You configure them with the set-hook or set-option commands, and you display them with show-hooks or show-options -H. These next two commands? Literally the same, no cap:
set-hook -g pane-mode-changed[style] 'display-message changed'
set-option -g pane-mode-changed[style] 'display-message changed'
Heads up: setting a hook without specifying an array key clears the hook and sets the first member of the array ๐ซถ
A command's after hook runs after that command completes โ except when the command is itself being run as part of a hook. Those after hooks are named with an after- prefix. For example, this one adds a hook that selects the even-vertical layout after every split-window:
set-hook -g after-split-window "selectl even-vertical"
And if a command fails? The command-error hook fires ๐. For example, this could be used to write to a log file:
set-hook -g command-error "run-shell \"echo 'a tmux command failed' >>/tmp/log\""
The hooks โจ
In addition to the after hooks, these are the hooks available:
alert-activityโ runs when a window has activity. Seemonitor-activity.alert-bellโ runs when a window has received a bell. Seemonitor-bell.alert-silenceโ runs when a window has been silent. Seemonitor-silence.client-activeโ runs when a client becomes the latest active client of its session.client-attachedโ runs when a client is attached.client-closedโ runs when a client is closed.client-createdโ runs when a client is created.client-detachedโ runs when a client is detached.client-focus-inโ runs when focus enters a client.client-focus-outโ runs when focus exits a client.client-resizedโ runs when a client is resized.client-session-changedโ runs when a client's attached session is changed.client-light-themeโ runs when a client switches to a light theme โ๏ธclient-dark-themeโ runs when a client switches to a dark theme ๐command-errorโ runs when a command fails.marked-pane-changedโ runs when the marked pane is set or cleared.pane-activityโ runs when there is new output in a pane.pane-bellโ runs when a pane receives a bell.pane-command-finishedโ runs when an OSC 133 command finishes in a pane.pane-command-startedโ runs when an OSC 133 command starts in a pane.pane-createdโ runs when a pane is created or respawned.pane-diedโ runs when the program running in a pane exits, butremain-on-exitis on so the pane has not closed ๐ญpane-exitedโ runs when the program running in a pane exits.pane-focus-inโ runs when the focus enters a pane, if thefocus-eventsoption is on.pane-focus-outโ runs when the focus exits a pane, if thefocus-eventsoption is on.pane-mode-changedโ runs when a pane changes mode.pane-mode-enteredโ runs when a pane enters a mode.pane-mode-exitedโ runs when a pane exits a mode.pane-movedโ runs when a pane is moved to another window.pane-prompt-closedโ runs when a prompt in a pane is closed.pane-prompt-openedโ runs when a prompt is opened in a pane.pane-resizedโ runs when a pane is resized.pane-set-clipboardโ runs when the terminal clipboard is set using thexterm(1)escape sequence ๐pane-shell-promptโ runs when an OSC 133 shell prompt starts in a pane.pane-title-changedโ runs when a pane title is changed.session-closedโ runs when a session is closed.session-createdโ runs when a new session is created.session-added-to-groupโ runs when a session is added to a session group.session-removed-from-groupโ runs when a session is removed from a session group.session-renamedโ runs when a session is renamed.session-window-changedโ runs when a session changes its active window.window-closedโ runs when a window is closed.window-createdโ runs when a window is created.window-layout-changedโ runs when a window layout is changed.window-linkedโ runs when a window is linked into a session.window-pane-changedโ runs when a window changes its active pane.window-renamedโ runs when a window is renamed.window-resizedโ runs when a window is resized. This may happen after theclient-resizedhook runs.window-unzoomedโ runs when a window is unzoomed.window-zoomedโ runs when a window is zoomed.window-unlinkedโ runs when a window is unlinked from a session.
Managing hooks ๐ ๏ธ
Hooks are managed with these commands:
set-hook
set-hook [-agpERTuw] [-B name:what:format] [-t target-pane] hook-name
[command]
Without -E or -R, this sets (or, with -u, unsets) the hook hook-name to command. And btw, the flags are the exact same as for set-option ๐ฏ
With -B, the name:what:format thing uses the same subscription syntax as refresh-client -B:
nameis the hook to run,whatselects the session, pane, all panes, window, or all windows,- and
formatis expanded once a second.
With -T, the hook is run only when format is true. For monitor hooks, name must begin with @. If a command is given, it gets stored as the @ hook command; otherwise only the monitor is created or replaced. Important note bestie: monitor hooks are not inherited โ the hook only runs from the scope where it was created. And with -u, the subscription named by -B is removed ๐ซก
With -E, you fire the user event named hook-name, and hook-name must begin with @.
With -R, you run hook-name immediately. Boom, right now, no waiting ๐ฅ
show-hooks
show-hooks [-Bgpw] [-F format] [-t target-pane] [hook]
Shows hooks โจ. The flags are the same as for show-options.
With -B, it shows the subscriptions installed with set-hook -B. With -F, format is used for each hook ๐
๐ญ MOUSE SUPPORT ๐ญ
okay bestie, if the mouse option is on, tmux lets you bind mouse events as keys. iconic. every key name is a mouse event (like MouseUp1) plus a location suffix. the suffixes are:
Paneโ the contents of a paneBorderโ a pane borderStatusโ the status line window listStatusLeftโ the left part of the status lineStatusRightโ the right part of the status lineStatusDefaultโ any other part of the status lineScrollbarSliderโ the scrollbar sliderScrollbarUpโ above the scrollbar sliderScrollbarDownโ below the scrollbar sliderEmptyโ empty space in the windowControlNโ on control range N
(peep the STYLES section for the tea on control ranges ๐ )
and here's the whole mouse event menu, no cap:
WheelUp WheelDown
MouseDown1 MouseUp1 MouseDrag1 MouseDragEnd1
MouseDown2 MouseUp2 MouseDrag2 MouseDragEnd2
MouseDown3 MouseUp3 MouseDrag3 MouseDragEnd3
SecondClick1 SecondClick2 SecondClick3
DoubleClick1 DoubleClick2 DoubleClick3
TripleClick1 TripleClick2 TripleClick3
so the SecondClick events fire on the second click of a double click โ even if there might be a third click coming that fires TripleClick instead of DoubleClick. messy? a little. that's the rules tho.
each one gets a location suffix tacked on, like MouseDown1Status. don't forget the suffix, she's important ๐
there's also the special token {mouse} or = that you can use as the target-window or target-pane in commands bound to mouse key bindings. it resolves to the window or pane the mouse event actually happened over โ like the window in the status line where button 1 got released for a MouseUp1Status binding, or the pane the wheel was scrolled over for a WheelDownPane binding. literally knows where you're pointing ๐ซถ
the send-keys -M flag can forward a mouse event to a pane.
and the default key bindings let the mouse select and resize panes, copy text, and switch windows using the status line. all of these kick in if the mouse option is turned on. turn it on bestie, it's the moment โจ
๐ FORMATS ๐
some commands take the -F flag with a format argument. it's a string that controls the output format of the command. format variables go inside #{ and }, like #{session_name}. the possible variables are listed in the table below (iykyk, we're getting there), or you can use the name of a tmux option to get that option's value, or the name of an environment variable. some variables have a shorter alias like #S. also: ## becomes a single #, #, becomes a ,, and #} becomes a }.
Conditionals happen when you prefix with ?. for each pair of two arguments: if the variable in the first of the pair exists and isn't zero, the second of the pair gets chosen, otherwise it keeps going. if none of the paired conditions match, the default value is chosen. if there's an unpaired final argument, that's the default. if not, the default is the empty string. for example:
#{?session_attached,attached,not attached}includesattachedif the session is attached, andnot attachedif it's unattached#{?automatic-rename,yes,no}includesyesif automatic-rename is enabled,noif not#{?#{n:window_name},#{window_name} - }includes the window name with a dash separator if there's a window name, or the empty string if the window name is empty#{?session_format,format1,window_format,format2,format3}includes format1 for a session format, format2 for a window format, or format3 for neither a session nor a window format
conditionals can be nested arbitrarily, go off. but inside a conditional, , and } must be escaped as #, and #}, unless they're part of a #{...} replacement. for example:
#{?pane_in_mode,#[fg=white#,bg=red],#[fg=red#,bg=white]}#W
String comparisons? yes ma'am. prefix two comma-separated alternatives with ==, !=, <, >, <= or >= and a colon. so #{==:#{host},myhost} gets replaced by 1 if you're running on myhost, otherwise 0. || and && evaluate to true if any or all of the comma-separated alternatives are true, like #{||:#{pane_in_mode},#{alternate_on}}. ! evaluates to true if the value is false and vice versa, like #{!:#{pane_in_mode}}. and !! converts a value to a canonical boolean form โ 1 for true, 0 for false โ so #{!!:non-empty string} evaluates to 1. slay.
An m does a glob(7) pattern or regular expression comparison. first argument is the pattern, second is the string to compare. an optional argument gives flags:
rโ the pattern is a regular expression instead of the default glob(7) patterniโ ignore casezโ do a fuzzy matchpโ likezbut returns a list of matched positions
a fuzzy match matches plain terms as sequences where each character must appear in order but not necessarily consecutively. terms beginning with ' are exact substring matches, ^ anchors a term at the start, $ anchors it at the end, ! inverts a term, and | separates alternative groups. examples bestie:
#{m:*foo*,#{host}}
#{m/ri:^A,MYVAR}
#{m/z:dev bash,dev:1 bash}
#{m/z:^dev | ^prod,prod:1 ssh}
A C searches pane content for a glob(7) pattern or regular expression, and evaluates to zero if it's not found, or a line number if it is. like m, an r flag means search for a regular expression and i ignores case. so: #{C/r:^Start} ๐ธ
Numeric operators! prefix two comma-separated alternatives with an e and an operator. an optional f flag after the operator means use floating point numbers, otherwise integers. then you can follow it with a number giving the decimal places for the result. the operators are:
- addition
+ - subtraction
- - multiplication
* - division
/ - modulus
mor%(heads up:%must be escaped as%%in formats that also get expanded by strftime(3)) - numeric comparison operators
==,!=,<,<=,>and>=
so #{e|*|f|4:5.5,3} multiplies 5.5 by 3 and gives a result with four decimal places, and #{e|%%:7,3} returns the modulus of 7 and 3. a replaces a numeric argument with its ASCII equivalent, so #{a:98} results in b. c replaces a tmux colour with its six-digit hexadecimal RGB value โ and if you give it an argument of f or b, it instead produces the SGR escape sequence to set the foreground or background colour respectively. cute AND useful ๐
You can cap the length of the resulting string by prefixing it with an =, a number and a colon. positive numbers count from the start of the string, negative from the end. so #{=5:pane_title} includes at most the first five characters of the pane title, and #{=-5:pane_title} the last five. a suffix or prefix can be given as a second argument โ if provided, it gets appended or prepended to the string when the length has been trimmed. for example #{=/5/...:pane_title} appends ... if the pane title is more than five characters. similarly, p pads the string to a given width, so #{p10:pane_title} results in a width of at least 10 characters. a positive width pads on the left, a negative on the right. n expands to the length of the variable and w to its width when displayed, like #{n:window_name}. and R repeats the first argument a number of times given by the second, so #{R:a,3} gives you aaa. periodt.
Prefixing a time variable with t: converts it to a string, so if #{window_activity} gives 1445765102, then #{t:window_activity} gives Sun Oct 25 09:25:02 2015. add p (t/p) and you get a shorter but less accurate time format for times in the past. r (t/r) gives the time relative to the current time, like 1m or 2m23s. d (t/d) gives the difference from the time to the current time in seconds (future times are negative). and you can give a custom format with an f suffix โ note that % must be escaped as %% if the format is separately being passed through strftime(3), for example in the status-left option: #{t/f/%%H#:%%M:window_activity}, see strftime(3).
The I: prefix interrogates the client. I/f is true if tmux believes the client supports the given terminal feature, like I/f:RGB. I/c is true if a client has the given terminfo(3) capability, like I/c:smcup. and I/e gives the value of a client environment variable, like #{I/e:FOO}. nosy in the best way ๐
The b: and d: prefixes are basename(3) and dirname(3) of the variable respectively. q: escapes sh(1) special characters โ with an h suffix it escapes hash characters (so # becomes ##), with a it escapes tmux command arguments, and with s it uses single quotes.
โ ๏ธ real talk: some variables likepane_titleandpane_pathare set by escape sequences received from the pane and may contain arbitrary content, including shell metacharacters. so useq:to escape these with commands passed torun-shell,if-shell, orpipe-pane. do not skip this bestie, it's giving security ๐
E: expands the format twice โ so #{E:status-left} is the result of expanding the content of the status-left option rather than the option itself. T: is like E: but also expands strftime(3) specifiers. S:, W:, P: or L: loop over each session, window, pane or client and insert the format once for each. L:, S: and W: can take an optional sort argument: /i, /n, /t to sort by index, name, or last activity time โ plus /r to sort in reverse order. /r also works with P: to reverse the sort order; panes are sorted by creation order by default. P: can additionally take /i to sort by pane index or /z to sort by z-index. so S/nr: sorts sessions by name in reverse order. for each of these, two comma-separated formats may be given, and the second one is used for the current window, active pane, or active session. for example, to get a list of windows formatted like the status line:
#{W:#{E:window-status-format} ,#{E:window-status-current-format} }
okay so inside the W: loop, bestie, there's a little bonus: user options (@name) from the windows next door are available with a next_ or prev_ prefix. So if the next window has a user option like @color, you get to call it next_@color. cute, right? ๐
Then O: loops over every single option โ and if an option is an array, it loops once for each array item, so you get every last crumb. ๐ O: can also be handed a flag to pick which options table you're rummaging through:
sโ the session tablewโ the window tablepโ the pane tablevโ the server table
g chooses global options. And the default? That's s. periodt.
V: loops over each environment variable. Its flags go like this:
sโ session environmentgโ global environmentcโ client environment
Then N: โ it checks whether a window name exists (with no suffix at all, or with the w suffix) or whether a session name exists (that's the s suffix). So for example N/w:foo gets replaced with 1 if there's a window named foo hanging around. ๐ฆ
A prefix that looks like s/foo/bar/: swaps foo for bar all the way through. And the first argument can be an extended regular expression, plus a final argument of i makes it ignore case โ like s/a(.)/\1x/i: would turn abABab into bxBxbx. ๐คฏ You can also use a totally different delimiter character so you don't trip over literal slashes sitting in your pattern. Like s|foo/|bar/|: will substitute foo/ with bar/ throughout. no cap.
Multiple modifiers? Separate them with a semicolon (;), as in #{T;=10:status-left}, which caps the resulting strftime(3)-expanded string at at most 10 characters. ๐
And there's more, because of course there is: the last line of a shell command's output can be dropped in using #(). So #(uptime) inserts the system's uptime. ๐
Heads up though โ when it's building formats, tmux does not wait around for #() commands to finish. It just uses the previous result from running that same command, or a placeholder if the command has never been run before. If the command hasn't exited, the most recent line of output gets used โ but the status line will not be updated more than once a second.
Commands get run using /bin/sh, with the tmux global environment set (peep the GLOBAL AND SESSION ENVIRONMENT section for that one).
An l says: interpret this string literally, do not expand it. Like #{l:#{?pane_in_mode,yes,no}} just becomes #{?pane_in_mode,yes,no}. untouched, protected, iconic. โจ
The A modifier shows one frame out of a list, taking turns: #{A/count:frame,frame,...} or #{A:frame,frame,...}. Each frame gets shown for count periods of 100 milliseconds before it hands over to the next one, and after the last it wraps right back to the first. If you don't give a count, one is used. ๐
Lowkey important: the A modifier is only expanded in the status line and pane-border-format. And if it's present, the status line or the pane borders get redrawn every 100 milliseconds. So like, #{A/2:|,/,-,\} shows those four frames in turn, changing every 200 milliseconds. slay. ๐
The following variables are available, where appropriate:
okay bestie the format variable table is a WHOLE saga and we're still in it, no thoughts just vibes โ here's the rest ๐
active_window_indexโ index of the active window in the session ๐ซถalternate_onโ1when the pane is living in the alternate screen โจalternate_saved_xโ the saved cursor X over in the alternate screenalternate_saved_yโ the saved cursor Y over in the alternate screenbracket_paste_flagโ the pane's bracketed paste flagbuffer_createdโ when the buffer got created โฐbuffer_fullโ the whole entire buffer contentbuffer_nameโ name of the bufferbuffer_sampleโ a lil sample of the start of the bufferbuffer_sizeโ size of the specified buffer in bytesclient_activityโ the last time the client had any activityclient_cell_heightโ height of each client cell, in pixelsclient_cell_widthโ width of each client cell, in pixelsclient_coloursโ how many colours the client supports ๐client_control_modeโ1if the client is in control modeclient_createdโ when the client was createdclient_discardedโ bytes discarded when the client fell behind ๐ญclient_flagsโ list of client flagsclient_heightโ height of the clientclient_key_tableโ the current key tableclient_last_sessionโ name of the client's last sessionclient_nameโ name of the clientclient_pidโ PID of the client processclient_prefixโ1if the prefix key has been pressed โจ๏ธclient_readonlyโ1if the client is read-onlyclient_sessionโ name of the client's sessionclient_termfeaturesโ the client's terminal features, if anyclient_termnameโ terminal name of the clientclient_termtypeโ terminal type of the client, if it's availableclient_ttyโ pseudo terminal of the clientclient_uidโ UID of the client processclient_userโ user of the client processclient_utf8โ1if the client supports UTF-8client_widthโ width of the clientclient_writtenโ bytes written to the clientcommandโ name of the command in use, if anycommand_list_aliasโ command alias when you're listing commandscommand_list_nameโ command name when you're listing commandscommand_list_usageโ command usage when you're listing commandsconfig_filesโ list of configuration files that got loaded ๐cursor_blinkingโ1if the cursor is blinkingcopy_cursor_hyperlinkโ the hyperlink under the cursor in copy modecopy_cursor_lineโ the line the cursor is chillin' on in copy modecopy_cursor_wordโ the word under the cursor in copy modecopy_cursor_xโ cursor X position in copy modecopy_cursor_yโ cursor Y position in copy modecopy_line_numbersโ1if line numbers are showing in copy mode ๐ขcopy_positionโ the position shown in the copy mode indicatorcopy_position_limitโ the limit shown in the copy mode indicatorcurrent_fileโ the current configuration filecursor_characterโ the character sitting at the cursor in the panecursor_colourโ cursor colour in the pane ๐จcursor_flagโ pane cursor flagcursor_shapeโ cursor shape in the panecursor_very_visibleโ1if the cursor is in very visible mode ๐cursor_xโ cursor X position in the panecursor_yโ cursor Y position in the panehistory_addedโ number of lines scrolled into the pane historyhistory_bytesโ number of bytes in the window historyhistory_collectedโ number of oldest pane history lines discarded at the history limithistory_generationโ a generation that gets incremented when the pane history is cleared or reflowedhistory_limitโ maximum window history lineshistory_sizeโ size of history, in lineshookโ name of the running hook, if any ๐ชhook_clientโ name of the client where the hook ran, if anyhook_fire_countโ how many times the hook has firedhook_fire_timeโ the last time the hook firedhook_lastโ the previous value for a monitor hookhook_monitor_formatโ format for a monitor hookhook_monitor_targetโ target for a monitor hookhook_paneโ ID of the pane where the hook ran, if anyhook_sessionโ ID of the session where the hook ran, if anyhook_session_nameโ name of the session where the hook ran, if anyhook_valueโ the new value for a monitor hookhook_windowโ ID of the window where the hook ran, if anyhook_window_indexโ index of the window where the hook ran, if anyhook_window_nameโ name of the window where the hook ran, if anyhost,#Hโ hostname of the local host ๐host_short,#hโ hostname of the local host, minus the domain nameinsert_flagโ pane insert flagkey_stringโ string representation of the key bindingkey_repeatโ1if the key binding is repeatable ๐key_noteโ note of the key bindingkey_prefixโ global key prefixkey_tableโ table name of the key bindingkey_commandโ command of the key bindingkey_has_repeatโ1if the list contains a repeatable keykey_string_widthโ maximumkey_stringwidth in the listkey_table_widthโ maximumkey_tablewidth in the listkeypad_cursor_flagโ pane keypad cursor flagkeypad_flagโ pane keypad flaglast_window_indexโ index of the last window in the sessionlineโ line number in the listloop_indexโ index of the item in theW:,P:,S:, orL:loop ๐loop_last_flagโ1if it's the last window, pane, session, or client in theW:,P:,S:, orL:loopmouse_all_flagโ pane mouse all flag ๐ญmouse_any_flagโ pane mouse any flagmouse_button_flagโ pane mouse button flagmouse_hyperlinkโ hyperlink under the mouse, if anymouse_lineโ line under the mouse, if anymouse_sgr_flagโ pane mouse SGR flagmouse_standard_flagโ pane mouse standard flagmouse_status_lineโ the status line the mouse event went down onmouse_status_rangeโ range type or argument of the mouse event on the status linemouse_utf8_flagโ pane mouse UTF-8 flagmouse_wordโ word under the mouse, if anymouse_xโ mouse X position, if anymouse_yโ mouse Y position, if anynext_session_idโ unique session ID for the next new session ๐next_window_activeโ1if the next window in theW:loop is activenext_window_indexโ index of the next window in theW:loopoption_array_keyโ array key, if the option is an array itemoption_has_array_keyโ1if the option array key is presentoption_has_valueโ1if the option value is presentoption_is_arrayโ1if the option is an arrayoption_is_hookโ1if the option is a hookoption_is_parentโ1if the option is inheritedoption_is_stringโ1if the option is a stringoption_is_userโ1if the option is a user optionoption_nameโ name of the optionoption_valueโ value of the optionoption_value_onlyโ1if only option values are gonna be shownorigin_flagโ pane origin flagpane_activeโ1if it's the active pane โญpane_at_bottomโ1if the pane is at the bottom of the windowpane_at_leftโ1if the pane is at the left of the windowpane_at_rightโ1if the pane is at the right of the windowpane_at_topโ1if the pane is at the top of the windowpane_bgโ pane background colourpane_bottomโ bottom of the panepane_command_durationโ current or most recent OSC 133 command duration, in secondspane_command_end_timeโ time the most recent OSC 133 command endedpane_command_runningโ1if an OSC 133 command is runningpane_command_start_timeโ time the current or most recent OSC 133 command startedpane_command_statusโ exit status from the most recent OSC 133 commandpane_current_commandโ the current command, if availablepane_current_pathโ the current path, if availablepane_deadโ1if the pane is dead ๐pane_dead_signalโ exit signal of the process in a dead panepane_dead_statusโ exit status of the process in a dead panepane_dead_timeโ exit time of the process in a dead panepane_fgโ pane foreground colourpane_flagsโ pane flagspane_floating_flagโ1if the pane is floating ๐pane_formatโ1if the format is for a panepane_heightโ height of the panepane_id,#Dโ unique pane IDpane_in_modeโ number of modes the pane is inpane_index,#Pโ index of the panepane_input_offโ1if input to the pane is disabled ๐pane_key_modeโ extended key reporting mode in this panepane_lastโ1if it's the last panepane_last_output_timeโ the last time the pane produced outputpane_last_prompt_timeโ time the most recent OSC 133 prompt beganpane_leftโ left of the panepane_markedโ1if this is the marked panepane_marked_setโ1if a marked pane is setpane_modal_flagโ1if the pane is modalpane_modeโ name of the pane mode, if anypane_output_generationโ a generation that gets incremented when pane output is processedpane_pathโ path of the pane (the application can set this one ๐)pane_pidโ PID of the first process in the panepane_pipeโ1if the pane is being piped ๐ฐ
okay bestie we're still deep in the variable list and it is long long, but you're doing amazing, keep scrolling ๐
pane_pipe_pidโ the PID of the pipe process, if there is onepane_private_modesโ list of the DECSET private modes that are enabledpane_pb_stateโ the pane's progress bar state ๐ฆ one ofhidden,normal,error,indeterminateorpaused(an application can set this one)pane_pb_progressโ the pane's progress bar progress percentage (yep, an application can set this too)pane_rightโ right edge of the panepane_search_stringโ the last search string you typed in copy modepane_start_commandโ the command the pane was started withpane_start_command_listโ the command the pane was started with, but quotedpane_start_pathโ the path the pane was started withpane_synchronizedโ1if the pane is synchronizedpane_tabsโ the pane's tab positionspane_title, aka#Tโ the title of the pane (an application can set this)pane_topโ top of the panepane_ttyโ the pane's pseudo terminalpane_unseen_changesโ1if there were changes in the pane while you were in a modepane_unzoomed_heightโ height of the pane when it is not zoomedpane_unzoomed_widthโ width of the pane when it is not zoomedpane_widthโ width of the panepane_xโ X position of the panepane_yโ Y position of the panepane_zโ Z position of the panepane_zoomed_flagโ1if the pane is zoomedpidโ server PIDprev_window_activeโ1if the previous window in theW:loop is activeprev_window_indexโ index of the previous window in theW:looprectangle_toggleโ1if rectangle selection is activatedrefresh_activeโ1if copy mode refresh is activescroll_positionโ your scroll position in copy modescroll_region_lowerโ bottom of the scroll region in the panescroll_region_upperโ top of the scroll region in the panesearch_countโ count of search resultssearch_count_partialโ1if the search count is a partial countsearch_matchโ the search match, if there is onesearch_presentโ1if a search was started in copy modeselection_activeโ1if a selection started and it changes along with the cursor in copy modeselection_end_xโ X position of the end of the selectionselection_end_yโ Y position of the end of the selectionselection_modeโ the selection modeselection_presentโ1if a selection was started in copy modeselection_start_xโ X position of the start of the selectionselection_start_yโ Y position of the start of the selectionserver_sessionsโ number of sessionssession_activeโ1if the session is activesession_activityโ time of the session's last activitysession_activity_flagโ1if any window in the session has activitysession_alertsโ list of window indexes with alertssession_attachedโ number of clients the session is attached tosession_attached_listโ list of clients the session is attached tosession_bell_flagโ1if any window in the session has a bellsession_createdโ time the session was createdsession_formatโ1if the format is for a sessionsession_groupโ name of the session groupsession_group_attachedโ number of clients that the sessions in the group are attached tosession_group_attached_listโ list of clients that the sessions in the group are attached tosession_group_listโ list of sessions in the groupsession_group_many_attachedโ1if multiple clients are attached to the sessions in the groupsession_group_sizeโ size of the session groupsession_groupedโ1if the session is in a groupsession_idโ unique session IDsession_last_attachedโ time the session was last attachedsession_many_attachedโ1if multiple clients are attachedsession_markedโ1if this session contains the marked panesession_name, aka#Sโ name of the sessionsession_pathโ working directory of the sessionsession_silence_flagโ1if any window in the session has a silence alertsession_stackโ window indexes in most recent ordersession_windowsโ number of windows in the sessionsocket_pathโ server socket pathsixel_supportโ1if the server has support for SIXELstart_timeโ server start timesynchronized_output_flagโ1if the pane has synchronized output enableduidโ server UIDuserโ server userversionโ server versionwindow_activeโ1if the window is activewindow_active_clientsโ number of clients viewing this windowwindow_active_clients_listโ list of clients viewing this windowwindow_active_sessionsโ number of sessions on which this window is activewindow_active_sessions_listโ list of sessions on which this window is activewindow_activityโ time of the window's last activitywindow_activity_flagโ1if the window has activitywindow_bell_flagโ1if the window has a bellwindow_biggerโ1if the window is larger than the client (it's giving main character window ngl)window_cell_heightโ height of each cell, in pixelswindow_cell_widthโ width of each cell, in pixelswindow_end_flagโ1if the window has the highest indexwindow_flags, aka#Fโ window flags, with#escaped as##window_formatโ1if the format is for a windowwindow_heightโ height of the windowwindow_idโ unique window IDwindow_index, aka#Iโ index of the windowwindow_last_flagโ1if the window is the last usedwindow_layoutโ window layout description, ignoring zoomed window paneswindow_linkedโ1if the window is linked across sessionswindow_linked_sessionsโ number of sessions this window is linked towindow_linked_sessions_listโ list of sessions this window is linked towindow_manual_heightโ manual height of the window, if it's setwindow_manual_widthโ manual width of the window, if it's setwindow_marked_flagโ1if the window contains the marked panewindow_modal_paneโ the modal pane in the window, if there is onewindow_name, aka#Wโ name of the windowwindow_offset_xโ X offset into the window if it is larger than the clientwindow_offset_yโ Y offset into the window if it is larger than the clientwindow_panesโ number of panes in the windowwindow_raw_flagsโ window flags with nothing escapedwindow_silence_flagโ1if the window has a silence alertwindow_stack_indexโ index in the session's most recent stackwindow_start_flagโ1if the window has the lowest indexwindow_visible_layoutโ window layout description, respecting zoomed window paneswindow_widthโ width of the windowwindow_zoomed_flagโ1if the window is zoomedwrap_flagโ pane wrap flag ๐
and that's not even the end bestie, keep going ๐
โจ STYLES โจ
okay bestie, so tmux has a whole bunch of options for telling it what the interface should look like โ the colours, the attributes, all of it ๐
Like status-style for your status line, that's the classic one.
plus โ and this is the fun part โ you can also drop styles inline into format options (think status-left) by wrapping them in #[ and ]. cute, right? ๐
A style can just be the single term default, which means "use the default style please" (and that default might come from an option, like status-style in the status line). Or it can be a list of the following, separated by spaces or commas:
fg=colourโ sets the foreground colour. The colour is one of:black,red,green,yellow,blue,magenta,cyan,white; if your terminal supports it the bright variantsbrightblack,brightred, ... ;colour0tocolour255from the 256-colour set;defaultfor the default colour;terminalfor the terminal default colour; or a hexadecimal RGB string like#ffffffโจbg=colourโ sets the background colour.us=colourโ sets the underscore colour.noneโ sets no attributes at all (turns off anything currently active).acs,bright(orbold),dim,underscore,blink,reverse,hidden,italics,overline,strikethrough,double-underscore,curly-underscore,dotted-underscore,dashed-underscoreโ sets an attribute. Any of these can be prefixed withnoto unset it. (acsis the terminal alternate character set, iykyk.)align=left(ornoalign),align=centre,align=rightโ aligns text to the left, centre or right of the available space, if appropriate.fill=colourโ fills the available space with a background colour if appropriate.dim=percentageโ dims the foreground and background colours by a percentage.width=Nโ sets the width of the styled area.Ncan be a column count or a percentage (for example50%).link=uri(ornolink) โ makes the styled text an OSC 8 hyperlink to uri, for example#[link=https://example.com]text#[nolink]. This only gets emitted to terminals that have thehyperlinksfeature (seeterminal-features); it works in the status line and in other formats drawn with styles. The link keeps going untilnolink,default, or an emptylink=shows up. Also, the uri can't contain spaces or commas and it's length-limited, so no novel-length URLs bestie ๐ญlist=on,list=focus,list=left-marker,list=right-marker,nolistโ marks the position of the various window list components in thestatus-formatoption:list=onmarks the start of the list;list=focusis the part of the list that should be kept in focus if the whole list won't fit in the available space (usually the current window);list=left-markerandlist=right-markermark the text used to show that stuff got trimmed off the left or right of the list when there isn't enough room.noattrโ do NOT copy attributes from the default style.push-default,pop-defaultโ stores the current colours and attributes as the default, or resets to the previous default. Apush-defaultaffects every later use of thedefaultterm until apop-default. Heads up though: only one default can be pushed (eachpush-defaultjust replaces whatever default was saved before) ๐range=left,range=right,range=session|X,range=window|X,range=pane|X,range=user|X,range=control|N,norangeโ marks a range for mouse events in thestatus-formatoption. When a mouse event lands in therange=leftorrange=rightrange, theStatusLeftandStatusRightkey bindings get triggered.
range=session|X, range=window|X and range=pane|X are ranges for a session, window or pane. These trigger the Status mouse key, with the target session, window or pane given by the X argument. X is a session ID, window index in the current session, or a pane ID. For these, the mouse_status_range format variable will be set to session, window or pane.
range=user|X is a user-defined range; it triggers the Status mouse key. The argument X will be available in the mouse_status_range format variable. X must be at most 15 bytes long, so keep it short bb.
range=control|N is a set of ranges for you to define custom behaviour with. N can be 0 through 9. When a mouse event occurs in the range=control|N range, the ControlN key binding is triggered. See โMOUSE SUPPORTโ for the deets.
set-defaultโ sets the current colours and attributes as the default, overwriting any previous default. > โ ๏ธ Warning bestie: the previous default cannot be restored. It's gone. Periodt.
Examples are:
fg=yellow bold underscore blink
bg=black,fg=default,noreverse
๐ธ NAMES AND TITLES ๐ธ
tmux is very much a "know the difference" kind of bestie: names and titles are two different things, and confusing them is a vibes crime ๐
Windows and sessions have names. Names are what you use to target them, and they're what shows up in the status line and in the various lists โ the name is the tmux identifier for a window or session.
Only panes have titles. A pane's title is typically set by whatever program is running inside that pane, using an escape sequence (the same way it'd set the xterm(1) window title in X(7)).
Windows themselves don't have titles โ a window's title is just the title of its active pane. And tmux itself may set the title of the terminal the client is running in; see the set-titles option for that one โจ
A session's name gets set with the new-session and rename-session commands. A window's name gets set with one of:
- A command argument (such as
-nfornew-windowornew-session). - An escape sequence (if the
allow-renameoption is turned on):
$ printf '\033kWINDOW_NAME\033\\'
- Automatic renaming, which sets the name to the active command in the window's active pane. See the
automatic-renameoption.
When a pane is first created, its title is the hostname. A pane's title can be set via the title setting escape sequence, for example:
$ printf '\033]2;My Title\033\\'
It can also be modified with the select-pane -T command ๐
๐ GLOBAL AND SESSION ENVIRONMENT ๐
When the server starts up, tmux copies the environment into the global environment; and on top of that, every session has its own session environment ๐ซถ
When a window is created, the session environment and the global environment get merged. If a variable exists in both, the value from the session environment wins. That merged result is the initial environment passed to the new process.
The update-environment session option can be used to update the session environment from the client when a new session is created or an old one is reattached. tmux also initialises the TMUX variable with some internal info so commands can be executed from inside, and the TERM variable with the correct terminal setting of screen.
Variables in both the session and global environments can be marked as hidden. Hidden variables don't get passed into the environment of new processes โ they can only be used by tmux itself (in formats, for example, see the โFORMATSโ section) ๐
The commands for messing with and viewing the environment are:
set-environment [-Fhgru] [-t target-session] variable [value]โ (alias:setenv) Set or unset an environment variable. If-gis used, the change happens in the global environment; otherwise it's applied to the session environment for target-session. If-Fis present, then value is expanded as a format. The-uflag unsets a variable.-rmeans the variable should be removed from the environment before starting a new process.-hmarks the variable as hidden.show-environment [-hgs] [-t target-session] [variable]โ (alias:showenv) Display the environment for target-session, or the global environment with-g. If variable is omitted, all variables get shown. Variables that have been removed from the environment are prefixed with-. If-sis used, the output is formatted as a set of Bourne shell commands.-hshows hidden variables (they're omitted by default, sneaky little things ๐).
set-environment [-Fhgru] [-t target-session] variable [value]
show-environment [-hgs] [-t target-session] [variable]
๐ STATUS LINE ๐
tmux has an optional status line, and it lives in the bottom line of each terminal. Iconic behaviour honestly.
By default the status line is enabled and one line high (you can disable it or make it multiple lines with the status session option ๐ซ), and it contains, from left to right: the name of the current session in square brackets; the window list; the title of the active pane in double quotes; and the time and date.
Each line of the status line is configured with the status-format option. The default is made of three parts: configurable left and right sections (which can contain dynamic content like the time or the output of a shell command โ see the status-left, status-left-length, status-right, and status-right-length options below), plus a central window list.
By default the window list shows the index, name and (if any) flag of the windows present in the current session, in ascending numerical order. You can customise it with the window-status-format and window-status-current-format options. The flag is one of the following symbols appended to the window name ๐
*โ Denotes the current window.-โ Marks the last window (previously selected).#โ Window activity is monitored and activity has been detected.!โ Window bells are monitored and a bell has occurred in the window.~โ The window has been silent for themonitor-silenceinterval.Mโ The window contains the marked pane.Zโ The window's active pane is zoomed.
The # symbol relates to the monitor-activity window option. And ooh โ the window name gets printed in inverted colours if there's an alert (bell, activity or silence) present ๐ณ
The colour and attributes of the status line are configurable too: the entire status line with the status-style session option, and individual windows with the window-status-style window option ๐
The status line automatically refreshes at an interval if it has changed, and that interval can be controlled with the status-interval session option.
Commands related to the status line are as follows:
clear-prompt-history [-T prompt-type]โ (alias:clearphist) Clear status prompt history for prompt type prompt-type. If-Tis omitted, then it clears history for all types. Seecommand-promptfor the possible values of prompt-type.
clear-prompt-history [-T prompt-type]
command-prompt</p> ๐ฌ
command-prompt [-1bCeFiklNP] [-I inputs] [-p prompts] [-t target-client]
[-T prompt-type] [template]
Opens up a command prompt inside a client, bestie. You'd use this from inside tmux to run commands interactively, like a little main character text box. ๐
If template is there, it gets used as the command. And with -F, that template gets expanded as a format. โจ
If -I shows up, inputs is a comma-separated list of the starting text for each prompt. If -p is given, prompts is a comma-separated list of prompts shown in order โ otherwise you just get one single prompt, built from template if present, or ':' if not. And -l disables splitting of inputs and prompts at commas, treating them literally. No splitting, no drama. ๐
Before the command runs, the first occurrence of the string โ%%โ and all occurrences of โ%1โ get replaced with the response to the first prompt, all โ%2โ get replaced with the response to the second prompt, and so on for however many prompts you have. You can replace up to nine prompt responses (โ%1โ through โ%9โ). And โ%%%โ is like โ%%โ but any quotation marks get escaped. ๐ฆ
-1โ makes the prompt accept only ONE key press, so the resulting input is a single character-kโ like-1but the key press gets translated to a key name-Nโ makes the prompt only accept numeric key presses-Cโ panes keep getting updated while the prompt is displayed-iโ executes the command every time the prompt input changes instead of waiting for the user to exit the command prompt-eโ makes BSpace cancel an empty prompt-Pโ opens the prompt inside a pane instead of on the status line
-T tells tmux what prompt-type you're working with. This changes what completions get offered when you hit Tab. The available types are: โcommandโ, โsearchโ. iykyk โจ
Now, these keys have special meaning in the command prompt, and it depends on the value of the status-keys option. Here's the whole vibe check, vi girlies and emacs girlies both eating:
- Cancel command prompt โ vi:
qยท emacs:Escape - Delete from cursor to start of word โ emacs:
C-w - Delete entire command โ vi:
dยท emacs:C-u - Delete from cursor to end โ vi:
Dยท emacs:C-k - Execute command โ vi:
Enterยท emacs:Enter - Get next command from history โ emacs:
Down - Get previous command from history โ emacs:
Up - Insert top paste buffer โ vi:
pยท emacs:C-y - Look for completions โ vi:
Tabยท emacs:Tab - Move cursor left โ vi:
hยท emacs:Left - Move cursor right โ vi:
lยท emacs:Right - Move cursor to end โ vi:
$ยท emacs:C-e - Move cursor to next word โ vi:
wยท emacs:M-f - Move cursor to previous word โ vi:
bยท emacs:M-b - Move cursor to start โ vi:
0ยท emacs:C-a - Transpose characters โ emacs:
C-t
With -b, the prompt is shown in the background and the invoking client doesn't exit until it gets dismissed. ๐ซถ
confirm-before ๐
confirm-before [-by] [-c confirm-key] [-p prompt] [-t target-client]
command
(alias: confirm)
Asks for confirmation before executing command, because we do NOT run things impulsively around here. ๐ If -p is given, prompt is the prompt to display โ otherwise a prompt gets constructed from command. It may contain the special character sequences supported by the status-left option. With -b, the prompt is shown in the background and the invoking client doesn't exit until it gets dismissed. -y changes the default behaviour (that's if Enter alone is pressed) of the prompt to run the command. And -c changes the confirmation key to confirm-key; the default is โyโ. โญ
display-menu ๐
display-menu [-OM] [-b border-lines] [-c target-client] [-C
starting-choice] [-H selected-style] [-s style] [-S
border-style] [-t target-pane] [-T title] [-x position] [-y
position] name key command [name key command ...]
(alias: menu)
Displays a menu on target-client. And target-pane gives the target for any commands run from that menu. Menus are iconic, we love a dropdown moment. ๐
A menu gets passed as a series of arguments: first the menu item name, second the key shortcut (or empty for none), and third the command to run when that menu item is chosen. The name and command are formats โ see the โFORMATSโ and โSTYLESโ sections. If the name begins with a hyphen (-), then the item is disabled (shown dim) and may not be chosen. And the name may be empty for a separator line, in which case both the key and command should be omitted. โจ
-bโ sets the type of characters used for drawing menu borders. Seepopup-border-linesfor possible values for border-lines.-Hโ sets the style for the selected menu item (see โSTYLESโ)-sโ sets the style for the menu (see โSTYLESโ)-Sโ sets the style for the menu border (see โSTYLESโ)-Tโ a format for the menu title (see โFORMATSโ)-Cโ sets the menu item selected by default, if the menu is not bound to a mouse key binding-xand-yโ give the position of the menu. Both may be a row or column number, or one of the special values below.
Okay so the special position values, memorize these fr fr:
Cโ Flag: Both โ the centre of the terminalRโ Flag:-xโ the right side of the terminalPโ Flag: Both โ the bottom left of the paneMโ Flag: Both โ the mouse positionLโ Flag: Both โ the position of the last menuWโ Flag: Both โ the window position on the status lineSโ Flag:-yโ the line above or below the status line
Or it can be a format, which gets expanded including these additional variables ๐
popup_centre_xโ Centered in the clientpopup_centre_yโ Centered in the clientpopup_heightโ Height of menu or popuppopup_last_xโ Left of the last menupopup_last_yโ Bottom of the last menupopup_mouse_bottomโ Bottom of at the mousepopup_mouse_centre_xโ Horizontal centre at the mousepopup_mouse_centre_yโ Vertical centre at the mousepopup_mouse_topโ Top at the mousepopup_mouse_xโ Mouse X positionpopup_mouse_yโ Mouse Y positionpopup_pane_bottomโ Bottom of the panepopup_pane_leftโ Left of the panepopup_pane_rightโ Right of the panepopup_pane_topโ Top of the panepopup_status_line_yโ Above or below the status linepopup_widthโ Width of menu or popuppopup_window_status_line_xโ At the window position in status linepopup_window_status_line_yโ At the status line showing the window
Each menu consists of items followed by a key shortcut shown in brackets. If the menu is too large to fit on the terminal, it is not displayed โ it just does not show up, no cap. ๐ญ Pressing the key shortcut chooses the corresponding item. If the mouse is enabled and the menu was opened from a mouse key binding, releasing the mouse button with an item selected chooses that item, and releasing the mouse button without an item selected closes the menu. -O changes this behaviour so that the menu does not close when the mouse button is released without an item selected โ the menu is not closed, and a mouse button must be clicked to choose an item. ๐ฑ๏ธ
-M tells tmux the menu should handle mouse events; by default only menus opened from mouse key bindings do so.
And these keys are available in menus:
Enterโ Choose selected itemUpโ Select previous itemDownโ Select next itemqโ Exit menu
display-message ๐
display-message [-aCIjlNpv] [-c target-client] [-d delay] [-t
target-pane] [message]
(alias: display)
Displays a message. If -p is given, the output is printed to stdout โ otherwise it's displayed in the target-client status line for up to delay milliseconds. If delay isn't given, the display-time option is used; a delay of zero waits for a key press. -N ignores key presses and closes only after the delay expires. If -C is given, the pane keeps getting updated while the message is displayed. If -l is given, message is printed unchanged โ no format expansion, literally as-is. Otherwise, the format of message is described in the โFORMATSโ section, and information is taken from target-pane if -t is given, otherwise from the active pane. ๐ธ
If -j is given, message is parsed as JSON and printed. ๐ฆ
-v prints verbose logging as the format is parsed, and -a lists the format variables and their values. Obsessed with a good debug moment.
-I forwards any input read from stdin to the empty pane given by target-pane. ๐ซถ
display-popup ๐
display-popup [-BCEkN] [-b border-lines] [-c target-client] [-d
start-directory] [-e environment] [-h height] [-s style] [-S
border-style] [-t target-pane] [-T title] [-w width] [-x
position] [-y position] [shell-command [argument ...]]
(alias: popup)
Displays a popup running shell-command (or default-command when it's omitted) on target-client. A popup is a rectangular box drawn over the top of any panes โ floating window energy, main character behaviour, we love it. ๐ If the command is run inside an existing popup, that popup gets modified. And in that case, only the -b, -B, -C, -E, -EE, -K, -N, -s, and -S options are accepted โ everything else is straight-up ignored. ๐
-E closes the popup automatically when shell-command exits. Two -Es (-EE) closes the popup only if shell-command exited with success. And -k allows any key to dismiss the popup instead of only โEscapeโ or โC-cโ. โจ
-x,-yโ these two set where the popup lands, and they mean exactly the same thing they mean over indisplay-menu. same energy, different command ๐-w,-hโ popup width and height, and bestie both of these can be a percentage too (just slap a%on the end). leave them out entirely and you get half the terminal size, no biggie.-Bโ no border around the popup. bye border. ๐-bโ sets what kind of characters get used to draw the popup borders. heads up though: if-Bis in play,-bis just ignored, like it's not even there. for the possible values of border-lines, go peek atpopup-border-lines.-sโ the style for the popup itself, and-Sโ the style for the popup border (see "STYLES").-eโ takes the formVARIABLE=valueand sets an environment variable for the popup. and yes you can stack it, specify it as many times as you want. โจ-Tโ a format for the popup title (see "FORMATS").-Cโ closes any popup on the client. all of them. gone.-Nโ disables any-E,-EE, or-koption you specified earlier. like an undo button for those three.
show-prompt-history [-T prompt-type]
(alias: showphist)
Shows you the status prompt history for the prompt type prompt-type. if you skip -T? then it just shows you the history for all the types, because why gatekeep. also, go check command-prompt for what values prompt-type is allowed to be. ๐ธ
๐ซง BUFFERS ๐ซง
OK so tmux keeps a whole little collection of named paste buffers, and every single one of them is either explicitly named or automatically named. let's break that down:
- explicitly named buffers get their name when you create them with the
set-bufferorload-buffercommands โ or when you rename an automatically named buffer usingset-buffer -n. - automatically named buffers just get handed a name like
buffer0001,buffer0002, and so on, counting up.
Once you hit the buffer-limit option, the oldest automatically named buffer gets deleted to make room. and the explicitly named ones? they're not subject to buffer-limit at all, they're built different ๐ โ and you can delete them yourself with the delete-buffer command.
You can add buffers using copy-mode, or with the set-buffer and load-buffer commands, and then paste them into a window with the paste-buffer command. and here's a handy one: if you run a buffer command and don't specify which buffer, it just assumes the most recently added automatically named buffer. iykyk.
Oh also โ there's a configurable history buffer maintained for each window too. by default it keeps up to 2000 lines, but you can change that with the history-limit option (see the set-option command above).
The buffer commands are as follows:
choose-buffer [-kNryZ] [-F format] [-f filter] [-K key-format] [-O sort-order] [-t target-pane] [template]
Puts a pane into buffer mode, where you can pick a buffer interactively from a list. every buffer gets shown on one line. there's a shortcut key shown on the left in brackets so you can just jump straight to one, or you can navigate the list and choose/manipulate stuff with the keys below. -Z zooms the pane. -y disables any confirmation prompts (living dangerously, love that).
the following keys may be used in buffer mode:
Enterโ Paste selected bufferUpโ Select previous bufferDownโ Select next bufferC-sโ Search by name or contentnโ Repeat last search forwardsNโ Repeat last search backwardstโ Toggle if buffer is taggedTโ Tag no buffersC-tโ Tag all bufferspโ Paste selected bufferPโ Paste tagged buffersdโ Delete selected bufferDโ Delete tagged bufferseโ Open the buffer in an editorfโ Enter a format to filter itemscโ Clear the current filterOโ Change sort orderrโ Reverse sort ordervโ Toggle previewF1orC-hโ Display helpqโ Exit mode
Once a buffer is chosen, %% gets replaced by the buffer name inside template, and the result is executed as a command. if you didn't give a template at all, then "paste-buffer -p -b '%%'" is what gets used. โจ
-Oโ the initial sort order, one ofcreation(time),name, orsize.-rโ reverses the sort order.-fโ an initial filter, and the filter IS a format โ if it evaluates to zero the item in the list isn't shown, otherwise it is shown. and if a filter would lead to an empty list, it's just ignored (no empty-list violence here ๐).-Fโ the format for each item in the list, and-Kโ a format for each shortcut key. both of these get evaluated once for each line.-Nโ starts without the preview.-kโ kills the pane when the mode is exited.- The
choose-buffercommand only works if at least one client is attached.
clear-history [-H] [-t target-pane]
(alias: clearhist)
Removes and frees the history for the specified pane. with -H it also wipes all the hyperlinks. clean slate bestie ๐งน
delete-buffer [-b buffer-name]
(alias: deleteb)
Deletes the buffer named buffer-name โ or, if you didn't name one, the most recently added automatically named buffer gets the boot.
list-buffers [-r] [-F format] [-f filter] [-O sort-order]
(alias: lsb)
Lists the global buffers. -F sets the format of each line, and -f sets a filter โ only buffers where the filter is true get shown. see the "FORMATS" section for that. -O picks the sort order, one of name, size, or creation (time), and -r flips that sort order around. ๐
load-buffer [-w] [-b buffer-name] [-t target-client] path
(alias: loadb)
Loads the contents of the specified paste buffer from path. if you hand it -w, the buffer also gets sent to the clipboard for target-client using the xterm(1) escape sequence โ if possible. and if path is -, the contents are read from stdin.
paste-buffer [-dprS] [-b buffer-name] [-s separator] [-t target-pane]
(alias: pasteb)
Inserts the contents of a paste buffer into the specified pane. don't specify a pane and it pastes into the current one. by default control characters are sanitized with vis(3); -S disables that. and with -d, it also deletes the paste buffer after.
when outputting, any linefeed (LF) characters in the paste buffer get replaced with a separator โ by default, carriage return (CR). you can set a custom separator with the -s flag. the -r flag means do no replacement (which is the same as a separator of LF). and if you pass -p, paste bracket control codes get inserted around the buffer, if the application has requested bracketed paste mode. ๐ซถ
save-buffer [-a] [-b buffer-name] path
(alias: saveb)
Saves the contents of the specified paste buffer to path. the -a option appends to the file instead of overwriting it. and if path is -, the contents get written to stdout.
set-buffer [-aw] [-b buffer-name] [-t target-client] [-n new-buffer-name] data
(alias: setb)
Sets the contents of the specified buffer to data. give it -w and the buffer also gets sent to the clipboard for target-client using the xterm(1) escape sequence โ if possible. the -a option appends to the buffer instead of overwriting it. and the -n option renames the buffer to new-buffer-name.
show-buffer [-b buffer-name]
(alias: showb)
Displays the contents of the specified buffer. simple as that. ๐
โจ MISCELLANEOUS โจ
Miscellaneous commands are as follows:
clock-mode [-t target-pane]
Displays a large clock. that's it that's the command. iconic honestly ๐
if-shell [-bF] [-t target-pane] shell-command command [command]
(alias: if)
Executes the first command if shell-command (run with /bin/sh) returns success โ or the second command otherwise. before it gets executed, shell-command is expanded using the rules from the "FORMATS" section, including the ones relevant to target-pane. with -b, shell-command runs in the background.
if you give it -F, then shell-command is not executed โ instead it's considered successful if it's neither empty nor zero (after formats are expanded). cute little logic check.
lock-server
(alias: lock)
Locks each client individually by running the command specified by the lock-command option. ๐
run-shell [-bCE] [-c start-directory] [-d delay] [-t target-pane] [shell-command [argument ...]]
(alias: run)
Executes shell-command using /bin/sh โ or, with -C, a tmux command โ in the background, without creating a window. before being executed, shell-command gets expanded using the rules specified in the "FORMATS" section. and if you give it argument values, they're available as #{1}, #{2}, and so on. for example:
run-shell 'myscript.sh #{1} #{2}' foo bar
with -b, the command runs in the background. -d waits delay seconds before starting the command. -E redirects the command's stderr to stdout instead of just ignoring it. if -c is given, the current working directory gets set to start-directory. and if -C is not given, any output to stdout is displayed in view mode (in the pane specified by -t, or the current pane if -t is omitted) after the command finishes. if the command fails, the exit status is displayed too. ๐
wait-for [-ELSUlv] [-F format] [-w waiter] name
(alias: wait)
When used with no options at all, this prevents the client from exiting until it gets woken using wait-for -S with the same channel. when -L is used, the channel is locked, and any clients that try to lock that same channel get made to wait until the channel is unlocked with wait-for -U.
With -E, tmux waits for the next event with name. events include hook and notification names, and user @ events generated by set-hook -E or set-hook -B. if -F is given, format must also be true. if -v is given, event payload keys get printed (whether or not format is true). ๐
-l lists the waiters for name, and -w wakes waiter on name immediately.
๐ EXIT MESSAGES ๐
So when a tmux client dips out, it leaves a little note behind, bestie. It's gonna be one of these:
detached (from session ...)โ the client just detached like a normal, well-adjusted queen. No drama.detached and SIGHUPโ the client detached AND its parent yeeted aSIGHUPat it (like when you dodetach-client -P). Rude but valid.lost ttyโ the client'stty(4)orpty(4)got destroyed out of nowhere. literally just evaporated ๐ญterminatedโ the client got taken out withSIGTERM.too far behindโ client's in control mode and lowkey couldn't keep up with all the data tmux was throwing at it. not the client's fault, it's just a lot ๐ซexitedโ the server exited because it had no sessions. empty house energy.server exitedโ the server exited when it caught aSIGTERM.server exited unexpectedlyโ the server crashed or otherwise bailed without telling the client why. the betrayal.
๐ฆ TERMINFO EXTENSIONS ๐ฆ
Okay so tmux speaks some unofficial bonus features from terminfo(5). You do NOT normally need to set these by hand โ instead just use the terminal-features option, periodt. But here's the whole lore anyway because I love you:
AXโ an existing extension that tells tmux the terminal supports default colours. โจBidiโ tells tmux the terminal supports the VTE bidirectional text extensions.Cs,Crโ set the cursor colour.Cstakes a single string argument and uses it to set the colour;Crtakes no arguments and restores the default cursor colour. If it's set, you can do a sequence like this to change the cursor colour from inside tmux:
$ printf '\033]12;red\033\\'
The colour is an X(7) colour, see XParseColor(3).
Cmg,Clmg,Dsmg,Enmgโ set, clear, disable or enable DECSLRM margins. These get set automatically if the terminal reports it's VT420 compatible.Dsbp,Enbpโ disable and enable bracketed paste. Set automatically if theXTcapability is present.Dseks,Eneksโ disable and enable extended keys.Dsesc,Enescโ disable and enable application escape key mode.Dsfcs,Enfcsโ disable and enable focus reporting. Set automatically if theXTcapability is present.Hlsโ set or clear a hyperlink annotation.Nobrโ tells tmux the terminal does not use bright colors for bold display.Rectโ tells tmux the terminal supports rectangle operations.Smolโ enable the overline attribute.Smulxโ set a styled underscore. The single parameter is one of:0for no underscore,1for normal underscore,2for double underscore,3for curly underscore,4for dotted underscore and5for dashed underscore. so many underscores, we're so spoiled ๐Setulc,Setulc1,olโ set the underscore colour or reset to the default.Setulcis for RGB colours andSetulc1for ANSI or 256 colours. TheSetulcargument is(red * 65536) + (green * 256) + bluewhere each is between 0 and 255.Ss,Seโ set or reset the cursor style. If set, a sequence like this can change the cursor to an underline:
$ printf '\033[4 q'
If Se is not set, Ss with argument 0 will be used to reset the cursor style instead.
Spbโ set the state and progress for the OSC9;4 progress bar.Swdโ set the opening sequence for the working directory notification. The sequence is terminated using the standardfslcapability.Sxlโ indicates the terminal supports SIXEL.Syncโ start (parameter is1) or end (parameter is2) a synchronized update.Tcโ indicate the terminal supports the 'direct colour' RGB escape sequence (for example,\e[38;2;255;255;255m).- If supported, this is used for the initialize colour escape sequence (which may be enabled by adding the 'initc' and 'ccc' capabilities to the tmux
terminfo(5)entry). - This is equivalent to the
RGBterminfo(5)capability.
- If supported, this is used for the initialize colour escape sequence (which may be enabled by adding the 'initc' and 'ccc' capabilities to the tmux
Msโ store the current buffer in the host terminal's selection (clipboard). See theset-clipboardoption above and thexterm(1)man page.XTโ this is an existing extension capability that tmux uses to mean the terminal supports thexterm(1)title set sequences and to automatically set some of the capabilities above.
๐ CONTROL MODE ๐
tmux serves a whole other textual interface called control mode, and it's giving "let the apps talk to tmux directly." It lets applications communicate with tmux using a simple text-only protocol. no frills, just vibes and bytes. ๐ซถ
In control mode, a client sends tmux commands or command sequences terminated by newlines on standard input. Each command will produce exactly one block of output on standard output. An output block is a %begin line followed by the output (which may be empty), and it ends with a %end or %error. The %begin and its matching %end or %error have three arguments: an integer time (as seconds from epoch), command number, and flags (currently not used). For example:
%begin 1363006971 2 1
0: ksh* (1 panes) [80x24] [layout {"V":2,"L":{"t":"p","w":80,"h":24,"x":0,"y":0,"a":true,"i":0,"I":"%2"}}] @2 (active)
%end 1363006971 2 1
The refresh-client -C command may be used to set the size of a client in control mode.
In control mode, tmux also outputs notifications. A notification will never occur inside an output block โ that's the rule, no cap.
The following notifications are defined:
%client-detached clientโ the client has detached.%client-session-changed client session-id nameโ the client is now attached to the session with ID session-id, which is named name.%config-error errorโ an error has happened in a configuration file.%continue pane-idโ the pane has been continued after being paused (if thepause-afterflag is set, seerefresh-client -A).%exit [reason]โ the tmux client is exiting immediately, either because it is not attached to any session or an error occurred. If present, reason describes why the client exited.%extended-output pane-id age ... : valueโ new form of%outputsent when thepause-afterflag is set. age is the time in milliseconds for which tmux had buffered the output before it was sent. Any subsequent arguments up until a single ':' are for future use and should be ignored.%layout-change window-id window-layout window-visible-layout window-flagsโ the layout of a window with ID window-id changed. The new layout is window-layout and the window's visible layout is window-visible-layout. If thenew-layoutsflag is set, both layout fields use the new format string; seerefresh-client -f. The window flags are window-flags.%message messageโ a message sent with thedisplay-messagecommand.%output pane-id valueโ a window pane produced output. value escapes non-printable characters and backslash as octal\xxx.%pane-mode-changed pane-idโ the pane with ID pane-id has changed mode.%paste-buffer-changed nameโ paste buffer name has been changed.%paste-buffer-deleted nameโ paste buffer name has been deleted.%pause pane-idโ the pane has been paused (if thepause-afterflag is set).%session-changed session-id nameโ the client is now attached to the session with ID session-id, which is named name.%session-renamed nameโ the current session was renamed to name.%session-window-changed session-id window-idโ the session with ID session-id changed its active window to the window with ID window-id.%sessions-changedโ a session was created or destroyed.%subscription-changed name session-id window-id window-index pane-id ... : valueโ the value of the format associated with subscription name has changed to value. Seerefresh-client -B. Any arguments after pane-id up until a single ':' are for future use and should be ignored.%unlinked-window-add window-idโ the window with ID window-id was created but is not linked to the current session.%unlinked-window-close window-idโ the window with ID window-id, which is not linked to the current session, was closed.%unlinked-window-renamed window-id new-nameโ the window with ID window-id, which is not linked to the current session, was renamed.%window-add window-idโ the window with ID window-id was linked to the current session.%window-close window-idโ the window with ID window-id closed.%window-pane-changed window-id pane-idโ the active pane in the window with ID window-id changed to the pane with ID pane-id.%window-renamed window-id nameโ the window with ID window-id was renamed to name.
๐ธ ENVIRONMENT ๐ธ
When tmux boots up, it peeks at these environment variables, like a little vibe check before the party starts:
EDITORโ if the command in here contains the stringvi, andVISUALis not set, tmux goes with vi-style key bindings. This gets overridden by themode-keysandstatus-keysoptions. (She's just a suggestion bestie, the options always win ๐ )HOMEโ the user's login directory. If it's unset, tmux goes and consults thepasswd(5)database instead, like asking the group chat when your friend isn't picking up.LC_CTYPEโ the character encodinglocale(1). Okay this one does two separate jobs, so pay attention:- For output to the terminal: UTF-8 gets used if you gave the
-uoption, or ifLC_CTYPEcontains"UTF-8"or"UTF8". Otherwise it's ASCII-only, and every non-ASCII character gets replaced with underscores (_). ๐ - For input:
tmuxalways runs with a UTF-8 locale, no negotiation. Ifen_US.UTF-8is provided by the operating system, that's what's used andLC_CTYPEis straight-up ignored for input. Otherwise,LC_CTYPEtells tmux what the UTF-8 locale is called on this system. And if the locale named byLC_CTYPEisn't available, or isn't a UTF-8 locale?tmuxexits with an error message. She said what she said ๐ญ
- For output to the terminal: UTF-8 gets used if you gave the
LC_TIMEโ the date and timelocale(1)format. It's what feeds the locale-dependentstrftime(3)format specifiers. โจPWDโ the current working directory to be set in the global environment. This can be genuinely useful if it contains symbolic links. But heads up: if the value here doesn't match the actual current working directory, the variable is ignored, and the result ofgetcwd(3)is used instead. No lying in this household ๐SHELLโ the absolute path to the default shell for new windows. See thedefault-shelloption for the details.TMUX_TMPDIRโ the parent directory of the directory that holds the server sockets. See the-Loption for the whole story.VISUALโ if the command in this variable contains the stringvi, use vi-style key bindings. Overridden by themode-keysandstatus-keysoptions, same asEDITOR.
๐ FILES ๐
~/.tmux.conf$XDG_CONFIG_HOME/tmux/tmux.conf~/.config/tmux/tmux.conf
โ these are the default tmux configuration file. Yes bestie, multiple locations, she's flexible like that ๐ฆ
/etc/tmux.confโ the system-wide configuration file.
โจ EXAMPLES โจ
Wanna spin up a brand new tmux session running vi(1)? Say less:
$ tmux new-session vi
Most commands have a shorter form, aka an alias. For new-session, that alias is new:
$ tmux new vi
Alternatively, you can just type the shortest unambiguous form of a command and it'll accept that. But if several commands match, it lists them out for you, like:
$ tmux n
ambiguous command: n, could be: new-session, new-window, next-window
Inside an active session, you can make a new window by typing C-b c โ that's Ctrl followed by the b key, followed by the c key.
Windows can be navigated with: C-b 0 (jump to window 0), C-b 1 (jump to window 1), and so on and so on; C-b n grabs the next window; and C-b p goes to the previous one. Hop around like you own the place ๐
A session can be detached with C-b d โ or by some outside event, like ssh(1) disconnecting on you, rude โ and then reattached with:
$ tmux attach-session
Type C-b ? and it lists the current key bindings for the current window. Use up and down to scroll through the list, or press q to bail out. ๐
If you want commands to run when the tmux server starts up, drop them in the ~/.tmux.conf config file. Some common faves include:
Changing the default prefix key:
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
Turning the status line off, or changing its colour:
set-option -g status off
set-option -g status-style bg=blue
Setting other options, like the default command, or locking after 30 minutes of inactivity:
set-option -g default-command "exec /bin/ksh"
set-option -g lock-after-time 1800
Creating new key bindings:
bind-key b set-option status
bind-key / command-prompt "split-window 'exec man %%'"
bind-key S command-prompt "new-window -n %1 'ssh %1'"
๐ SEE ALSO ๐
๐ AUTHORS ๐
Nicholas Marriott <nicholas.marriott@gmail.com> โ the icon, the legend, the one who made your terminal life cute fr fr ๐
And that's the whole page bestie, you made it to the end!! ๐ This version is the Debian one, dated September 23, 2026, for the page TMUX(1) โ which, yes, means you genuinely read all of it and I'm so proud of you, that's main character energy if I've ever seen it. Go forth and multiplex ๐ โจ๐ซถ
๐ฆ where this page comes from
- arch rolling: tmux 3.8-1 ยท BSD
- fedora 44: tmux 3.8-2.fc44 ยท ISC AND BSD-2-Clause AND BSD-3-Clause AND SSH-short AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: tmux 3.8
- Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms