[#trmltplx]:

Terminal Multiplexing

Intro
tmux

In an interview with Nicholas Marriott, tmux's creator explains that tmux was generated because of a desire to modify the program called “screen”, but the challenge of working with screen's code were so significant that making some desired changes were “implausible”.

tmux was meant to be a replacement for screen.

OpenBSD 4.6 upgrade guide: section about tmux being imported to base notes that with this release (from October 18, 2009), tmux became part of OpenBSD. This integration with the OpenBSD operating system provided a wider install base for tmux, and did some other things that helped the software development from tmux. This is discussed by an interview with Nicholas Marriott. Theo de Raadt, the founder of OpenBSD, was interviewed (on camera) and mentioned the start of how tmux started to get integrated into OpenBSD: “Nicholas had already written it all, and then I became aware that there was a screen replacement. And, that same day, he had an account. Once he had an account, the idea was that other developers were immediately able to accelerate his process and tune it up”. (This is quoting from an interview. The quote came from about 24 minutes into BSD Now (The Place To Be... Es Dee) Episode 006: Doing it de Raadt Way.) Theo's take on this is not a one-sided opinion (from OpenBSD's vantage point), as an interview with Nicholas Marriott also discusses benefits from this integration (from the perspective of tmux's creator).

Reliability

Sadly, this code might not be quite up to par as some of the other code from OpenBSD: there have been some cases where the tmux server has been known to quit (crash?) on an otherwise stable system. The ability to interact with the features of the tmux “server” may be largely ignored by people who use the software in simple ways, but the server is actually quite critical to the program's operation. When the server quits, that may cause termination of all programs in any tmux session by the same user.

So, this is a newer project, but running with caution may be prudent.

Then again, this commentary may be rather specific to the tmux that was bundled with OpenBSD 5.2 (which is now multiple versions old). The project may have improved from that time. (Note that OpenBSD may be the best operating system from which to judge tmux stability. This is because of how the creator of tmux has been known to closely work with the OpenBSD project.)

Variations

On OpenBSD, there are multiple packages.

  • OpenBSD Ports: page for “screen” identifies one port as “static”, which means that it does not require a bunch of external files. This version may be easier to get working if some files become inaccessible (such as if a directory is on a “mount point” that isn't mounted).
  • The other variation is called “shm”, which stands for “shared memory”, and the OpenBSD Ports page notes that this is “useful for brltty”. The BRLTTY project helps people use the text mode console (in an operating system running the Linux kernel) with “a refreshable braille display”.

The “static” option may be the best for most people. This is assuming:

  • They aren't using BRLTTY
  • They aim for simplicity, rather than having a fully optimized experienced (which may use slightly less disk space) that may have higher requirements (regarding what files exist)
screen
License

Soft-Panorama “History of” ... “Screen development” starts off by saying, “Screen was initially called BSD screen.” Later, the article goes onto say “In 1990 Oliver Laumann handed over maintenance of the code to Jürgen Weigert and Michael Schroeder at the University of Erlangen-Nuremberg, who later moved the project to the GNU Project. They added such features such as split-screen, cut-and-paste, and screen-sharing.” (These are some of the most cherished features, other than detachability.)

This is discussed by: Abram Hindles history of “Screen”: “License” section states, “It was apparent that Laumann did not want to add certain features to screen that the community seemed to want”. “iScreen version 3.1.1” ... “was the first version” ... “to be released under the GPL (officially). Later versions of screen were licensed under the GPL Version 2.” Wikipdia's article on Screen: Talk page: section called “History?”, Karnesky states, “2.1b apparently had license confusion (devs stating that it was under the GPL, but shipped with an MIT-style license), 3.2 definitely shipped with the GPL, and 3.1.1 might have (the latter according to ChangeLog). All of this was in 1991/1992.” Wikipdia's article on Screen: Talk page: section called “Early screen version history as reconstructed from comp.sources.unix archive”

Old version(s)
ftp://ftp.isc.org/usenet/comp.sources.unix/volume17/screen2/
Others

Some programs that may have provided some similar technology may include ones that are named or referenced in this section:

window
window was mentioned by: “OpenBSD Upgrade Guide: 4.5 to 4.6”, section on tmux “moved from port to base”, OpenBSD 4.5 manual page for the window command It was generally viewed as technically inferior to the “screen” program (even if the license was preferable).
Starting a session
tmux

tmux

This ends up being the same as running “ tmux new-session ”.

Upon starting a session, the session will have a “size” assigned. Currently, this is discussed in further length by a sub-section of Qemu: Output directly to text mode.

screen

screen

After running this, press Space for a secondpage of help, or Return to start the first screen window.

If the person presses the Space bar on the first screen, then some codes related to “capabilities” are shown. e.g.: “+copy +remote-detach +power-detach +multi-attach +multi-user +font +color-256” “+utf8 +rxvt +builtin-telnet

help
tmux
The command prefix (generally Ctrl-B), followed by ?
screen
The command prefix (generally Ctrl-A), followed by ?
Sending the command prefix as literal input

In tmux, the command prefix is a Ctrl-B. But what if you want to send a Ctrl-B to the program?

In screen, the command prefix is Ctrl-A. But what if you want to send a Ctrl-A to the program? (For example, the program called "minicom" uses Ctrl-A to call up a menu of options.)

The need to send the command prefix to other programs may be somewhat uncommon. However, if you have a need to do so, then knowing how to do this is certainly nice. Since those keystroke sequences are special, these programs took away the ability to just press thsoe keystroke sequences to send the corresponding ASCII character to a program that is being run. How to handle that?

tmux
The command prefix is generally Ctrl-B. To send a Ctrl-B to whatever program is being run, simply press Ctrl-B twice.
screen
The command prefix is generally Ctrl-A. To send a Ctrl-A to whatever program is being run, press the command prefix (Ctrl-A) followed by the letter a.
Creating a window
tmux
The command prefix (generally Ctrl-B), followed by c
screen
The command prefix (generally Ctrl-A), followed by c
Changing active window
tmux

To get to window #2, press the command prefix (generally Ctrl-B), followed by 2. Likewise, the first nine windows may be reached by pressing the command prefix, followed by a number.

To go to the next active window, press the command prefix (generally Ctrl-B), followed by n. To go to the previous one, press the command prefix (generally Ctrl-B), followed by p.

By default, changing windows will affect every copy of tmux that is using the same tmux “session”. If one copy of tmux changes which window is being interacted with (viewed, and where keystrokes get sent to), then every copy of tmux using that session will also change which window is being viewed. This is different from the “screen” program. However, the behavior of the “screen” program may be implemented. Details are in the section about resuming sessions.

If the “mouse-select-window” option is “on”, clicking the name of a window can switch to it.

(Another option may involve the process of listing windows, which is the next topic.)

screen

The keys are the same as tmux, except of course that the command prefix is generally Ctrl-A. So there is Ctrl-A followed by either n, p, or a single digit number (as described further in the section about tmux).

A key difference between screen and tmux is that each copy of screen retains its own view to the session being connected to. If one copy of screen switches which window is active, then other copies of screen will not automatically change which window is being interacted with.

If screen is using multiple window groups, Soft-Panorama “History of” ... “Screen development” quotes Michael Schroeder as stating, “next/prev will not leave the group”. However, pressing Ctrl-A followed by " sequence twice can be used to switch groups. (The first time that Ctrl-A followed by " is pressed, the windows of the current window group will be listed. Then, pressing the same sequence (Ctrl-A followed by ") again can be used to “show the other windows.” (The latter quote is from the Soft-Panorama page, referenced earlier.)

(Another option may involve the process of listing windows, which is the next topic.)

Listing (some) windows

If a status bar is shown, then that status bar may show some window titles. However, the status bar provides a limited amount of space for showing the names of windows.

tmux

The command prefix (generally Ctrl-B), followed by w will run the “choose-window” command that is internal to tmux. This will show a screen listing windows. The user may then use this screen to select an active window. If switching windows wasn't desired, simply press q to make the screen go away.

command prefix (Ctrl-B), w

screen

The nicer way is probably to use the command prefix (generally Ctrl-A) followed by " (ASCII code 38, “quotation mark”/“shift-apostraphe”). This shows all of the windows in a “window group”, and may have been added to screen about February 6, 2007. The display will be more similar to what tmux shows with command prefix + w.

The command prefix (generally Ctrl-A), followed by w will show a message that displays numbers for windows have been created and not yet destroyed. The message also shows what command is being run in each window. This can be helpful in remembering which windows exist, and how to jump straight to a desired window.

killing a window/pane
tmux

To close an active pane, use the command prefix (generally Ctrl-B), followed by x. To close an active window, use the command prefix (generally Ctrl-B), followed by an ampersand (“&”).

The user may then be prompted.

screen
The command prefix (generally Ctrl-A), followed by x
detaching
tmux

One method may be to disconnect a connection to the terminal being used. For example, close an SSH session, or hang up a phone connection if using a dial-up modem.

A cleaner method may be to simply specify the “detach” option, by pressing the command prefix (generally Ctrl-B), followed by d.

screen

The instructions match those of tmux, except, of course, that the default command prefix is different.

However, experience has shown that disconnecting like that might, sometimes, cause the screen session to be closed (rather than detached). Therefore, use the command prefix sequence to detach an active session before intentionally breaking any remote access connections. That approach is known to be more reliable.

Resuming a session
tmux

If there is only one detached session, then running “ tmux attach ” will do the trick.

Otherwise, a session name can be speciifed so that the right session is re-attached. find the name of the session with “ tmux list-sessions ”. Then, use: “ tmux attach sessionName ”. e.g.: “ tmux attach-session sessionName

When starting tmux with no command line parameters, “ tmux ” acts like there was a “new” parameter used, so it does the same thing as running: “ tmux new-session

Another option is to create a new session which targets an old session. This allows the new session to view all of the programs that are running in an old session. However, certain activity will remain independent of any already-existing session. This includes switching which window is active. By doing this, every session can interact with the same programs, but each session can independently decide which window to be viewing.

screen

One method is to use: “ screen -R ”. This will try to attach to an existing detached session. However, if there are no existing detached sessions, it will simply create a new session.

Another option is to use: “ screen -r ”. If the session is not found, then screen will exit.

There may also be some other variations. Run “ screen --help | $PAGER ” and see examples related to -d and -DD.

Quitting
tmux

To entirely quit, one option is to close all active windows. Another option is to use the command prefix (generally Ctrl-B), followed by a colon (“:”), followed by either “kill-session” or “kill-server” (followed by the Enter key).

Those are the typical ways: there may be others. There may be other ways to rapidly close many programs, including running “ tmux detach-client -a -t sessionName ” or to use the “destroy-unattached” command.

screen
The command prefix (generally Ctrl-A), followed by \ will cause screen to prompt, “Really quit and kill all your windows [y/n]
The status bar

You can make some changes to the status bar. Here are some details for that:

tmux
Setting the color

Press the command prefix (generally Ctrl-B).

Then press “Ctrl-:” (a colon, which is Shift+Semi-colon)

Then type something like:

set -ag status-style "bg=red fg=cyan"

(And then press the Enter key.)

(Regarding the hyphen'ed commands, “a” is to “append” an item, and “g” causes a “global” affect within the software.)

Adding a note

A note can be added to the status bar. For example, tmux's man page shows a value for status-left that adds a yellow message that displays the percentage of battery life remaining, useful on laptops. To add that, press the command prefix (generally Ctrl-B).

Then type:

:set -g status-left "#[fg=yellow,bold]#(apm -l)%%#[default] [#S]"

(And then press the Enter key.)

Misc comments

If “mouse-select-window” is “on”, clicking the name of a window can switch to it.

For status bar enhancements: LukaszWrobel.pl tmux splitting tutorial mentions highlighting a program. That can be done with “set-window-option -g window-status-current-bg yellow”

Hawk Host Blog: Tmux: The terminal Multiplexer (Part 2) also shows making colors, and also discusses placing information (like load averages) in the status bar.

screen

According to comments from Byobo review, placing “caption always” can implement one of the most desired features that some people get from an add-on named Byobo. Surely adding one line of a text file ought to be simpler, and less overhead, than installing the Byobo add-on (which is GPLv3).

[#tmxscrbk]: Scrollback (in terminal multiplexer programs)
[#tmuxscbk]: tmux

The command prefix (generally Ctrl-A), followed by either [ or Page Up. If pressing Page Up, scrollback will also go back one screen.

To leave scrollback mode, press q or Escape (by pressing the Esc key, or pressing Ctrl-[) or the interrupt character sequence (Ctrl-C). Note that leaving the scrollback mode may take a bit of time (about a second or two), so be patient if the mouse cursor does not instantly show up back on the main screen.

Once scrollback mode is enabled, certain keystrokes the next keys to use will depend on which key binding tables are being used by tmux. The topic of key bindings is discussed further, but first a quick primer of some default behavior is provided here.

In “emacs” mode, the up arrow and down arrow can be used to move a single line, and Page Down may be used to go down a full screen. Page Up, of course, can go up a screen. However, out of all of these cursor movement keys, only Page Up is used for entering the scrollback mode.

Emacs keys and vi keys in tmux

Once scrollback mode is enabled, the next keys to use will depend on which key binding tables are being used by tmux. The behavior depends on the value of the ${VISUAL} environment variable.

Contrasting Emacs mode and vi mode in tmux

In general, the Emacs keys are more pleasant (as they allow usage of the arrow keys, and Page Down and Page Up), and modern terminals usually support the cursor movement keys used by Emacs. However, some terminals might not fully support the Emacs keys, and the vi keys are more universally compatible.

The Emacs program uses a Meta key which is typically the Alt key (so M-w may be entered by holding Alt and pressing w), although another option in Emacs is to press the Escape key sequence (by pressing the Esc key, or Ctrl-[) and then pressing the desired letter (such as the letter w for this example). This is commonly supported by many programs that provide some Emacs keyset compatibility. However, pressing the Escape key sequence is NOT treated as a Meta character in tmux's copy mode. This means that tmux's copy mode does not act like many other Emacs programs. People using very limited terminals may find that the “vi” mode is more compatible.

Usually tmux will use the “emacs-edit” (EMacs) mode, although if the ${VISUAL} contains the phrase “vi”, then tmux may use the “vi-edit” mode.

To see which mode is being used, enter the command mode by pressing the command prefix (Ctrl-B by default), and then press a colon (“:”). Then type “showw -g mode-keys” (without the quotation marks) and press the Enter key. Then, press the q key to quit displaying which mode is being used.

The key bindings mode may also be changed. An an example, to use the “vi-edit” tables, enter the command mode by pressing the command prefix (Ctrl-B by default), and then press a colon (“:”). Then type “setw mode-keys vi” (without the quotation marks) and press Enter. (Alternatively, instead of typing “setw”, the long command of “set-window-option” may be used.)

Available keys

To list all of the keys available while in Emacs copy-mode, enter the command mode by pressing the command prefix (Ctrl-B by default), and then press a colon (“:”). Then type “lsk -t emacs-copy”. To see the keys available while in vi copy-mode, enter the command mode by pressing the command prefix (Ctrl-B by default), and then press a colon (“:”). Then type “lsk -t vi-copy” (without the quotation marks) and press Enter. Instead of the shorter “lsk” command, the longer “list-keys” command may be used.

tmux's manual page also documents some keys that may be used for performing some functions, like moving the cursor around.

Some popular keys for vi mode

For terminals that don't support these cursor movement keys, the vi-compatible keys (h=down, j=down, k=up, l=right, Ctrl-F for Page Down, Ctrl-B for previous page, / for search, n for next occurrence of a search term).

screen

Press the command prefix (which defaults to Ctrl-A) followed by the Escape sequence (which may be used by pressing the Esc key, or pressing Ctrl-[).

At this point, cursor movement keys (like arrow keys) will often work. (However, don't try pressing the space bar to go down a page, because that will initiate text selection. That is discussed further in the section on copying and pasting.)

The Escape sequence (which may be used by pressing the Esc key, or pressing Ctrl-[) can be used to exit this scrollback mode.

Copy and Paste
tmux
Copying from tmux

Enter scrollback mode. (See tmux scrollback.)

Most new users probably prefer a non-vi editor, such as “nano”. In that case, they will probably be in Emacs mode. In that case, pressing Ctrl-Space will start selecting text. If tmux is in “vi mode” instead, then the key to start selecting text is simply the Space bar.

Once selecting text, the cursor may be moved using standard cursor movement keys. The character under the keyboard cursor will not be selected, so move the keyboard cursor to be just after the text that should be highlighted. On a color terminal, the selected text may be highlighted.

Now is where things can potentially start to get really interesting/complicated. Copying text may work simply, or not. In many cases, tmux will be in Emacs copying mode, and pressing Alt-w will work. (Technically, the keystroke to use is called Meta-w, but since most common keyboards do not have a key called “Meta”, “Alt” is what gets used.)

If this was successfully copied, then the text shows up in a “paste buffer”. The paste buffers may be viewed by pressing the command prefix (Ctrl-B) followed by a “hash mark” (“#”). After viewing the paste buffer(s), press q to exit the paste buffer viewing.

However, there are some potential cases where that might not work as well. If there's one thing that screen really beats tmux at, it is simplicity in copy and paste (using compatability and defaults). As noted in tmux scrollback, the keys will depend on whether tmux is using an Emacs compatibility mode, or a vi compatibility mode. If in Emacs compatability mode, the Alt key might work as a Meta key. (That seems to work on local systems, as well as when using PuTTY.) However, some terminals might not support that keymapping in a way that tmux will understand it. For most programs that encounter this keymapping issue, the use of a Meta may be simulated by pressing the Escape sequence (which may be used by pressing the Esc key, or pressing Ctrl-[). However, in tmux, the Escape sequence will exit scrollback mode, which means that the Escape key cannot be used to initiate the system's Meta key to start a copy.

One work-around is to stop using Emacs compatability mode. See details on how to do this in the section about tmux scrollback.

Pasting from tmux

Method #1: exit the scrollback mode, if the program is still in scrollback mode. Then, press the command prefix sequence (typically Ctrl-B) and press right square bracket (“]”).

There may also be methods by using the Emacs compatability keyset or vi compatability keyset. (Those are documented by tmux's manual page.)

That should work for simply pasting tihe last thing that has been copied. Surely this has the potential of getting more complex, due to support for multiple paste buffers. This is discussed in more detail by tmux's manual page: “Buffers” section.

Copy and Paste in screen

The directions provided for scrollback (in terminal multiplexer programs) actually place screen in what it calls “copy mode”.

Once screen is in “copy mode”, cursor movement keys will generally work fine.

To start copying, press the Space bar. To stop copying, press the Space bar. This will copy the desired text, and exit the scrollback mode.

To paste, press the command prefix (which defaults to Ctrl-A) followed by the right square bracket key.

Pane (/Window) Handling
Splitting: making a new pane/region
tmux

Press the command prefix (generally Ctrl-B), followed by either quotation marks (“"”) or a percent sign (“%”).

  • Quotation marks will cause a horizontal bar to split things, so the resulting panes are stacked vertically. The new pane will be on the bottom. Although the previous pane is split horizontally, tmux documentation calls this a “vertical” split (presumably because of the position of the new pane).
  • Percent sign will cause a vertical bar to split things, so the resulting panes sit next to each other, side-by-side, horizontally. The new pane will be on the right.
screen

The command key (generally Ctrl-A), followed by S, splits horizontally (creating a new region in a position located vertical of the other region).

The command key (generally Ctrl-A), followed by a pipe (“|”), splits horizontally (creating a new region in a position located vertical of the other region).

Switching panes/regions
tmux

To switch panes, the most straightforward method is often to press Ctrl-B and press an arrow key. When there are multiple panes, that allows the user to move the focus in the direction specified by the arrow key. Each pane may also be visited sequentially by pressing Ctrl-B followed by the letter o. An alternative may be Ctrl-B and then ; to go to the previously active pane.

Panes are numbered, which may be seen with Ctrl-B and then q. Each pane will show an ASCII art number for a short period of time (perhaps slightly over a second). If the pane's number is pressed during that time, that pane will become the active pane.

If “mouse-select-pane” is “on”, clicking on a pane can make that pane become active. (Of course, that requires mouse support, so that might not be available with some terminals like those created with a simple command prompt by just using SSH.)

screen

Then press the command key (generally Ctrl-A) and press the Tab key to make the other section active. You may then create a new window, or switch windows, in that section.

Removing panes/regions
tmux

The command prefix (Ctrl-B) and then x will ask a user if a pane should be killed. If there is only one pane in the window, this ends up having the same effect as using the command prefix (Ctrl-B) and then ampersand (“&”), which prompts the user about killing a while window.

screen
Quitting region layout, showing only one region

If you want to remove one screen from the region layout, which causes the focused-on region to become a full-screen window, use the command prefix (Ctrl-A) followed by Q. (That does need to be a capital letter Q.) That causes the window to Quit being part of the region layout, done by breaking the region out of the boundaries that were created by prior splitting.

The way that command prefix (Ctrl-A) followed by Q gets implemented is to use a command that is internal to screen. The command is called “only”.

Removing current region

If, on the other hand, the goal is just to remove a single region, then that can be done with command prefix (Ctrl-A) followed by X (using a capital letter X).

Resizing panes/regions
tmux

Press the command prefix (generally Ctrl-B), followed by Ctrl-arrow key.

Resizing a remote connection

StackOverflow answer states, “The Ctrl+arrow keycodes were introduced by xterm” ... “Actual VT100 and VT220 terminals did not have separate keycodes for such combinations.” A post from a user on the tmux mailing list states, “I believe the ability to send modifiers (ctrl, alt, shift) with arrow-keys is a feature added by xterm and copied by other terminal-emulators, it's not part of the original VT100/VT220 feature-set.”

The older standards, which were probably a bit simpler and which are supported most widely, did not support Ctrl-arrow keys. The result is that many programs don't support Ctrl-arrow keys consistently. Holding Ctrl and pressing arrow keys will typically send some sort of data, but that data is not consistently recognized by all terminals/programs.

(Note: this is documented in tmux's manual page. When tested, this did not seem to work well from Microsoft Windows using PuTTY.)

There are some ways to deal with this.

Try a larger resize

This probably won't work, but pressing the command prefix key (Ctrl-B by default) and then holding the Meta key and pressing arrow keys. If that works, the window may resize by 5.

This probably won't work for the same reason that holding Shift, and then pressing an arrow key, will provide unsatisfactory results. However, it may be fast to try.

Just run the command directly

This is quite likely to work, and may be the fastest way to accomplish the goal in the short term.

Press the command prefix key (Ctrl-B by default), then the colon, and type “resize-p -D 1

The “-D” refers to moving the bottom edge further down. Alternatives are “-L” to move the left side further left, and “-R” to move the right side further to the right. If no letter is specified, that is like the default option, “-U”, to move the top side further up.

The “ 1” is optional; the default value of one specifies that the change will affect only one row or column (depending on the direction).

If you forget the exact command to type, presing the Command Prefix and pressing ? should show help. The Ctrl-arrow keys may be bound to the command by default, and this may be the last entries in the list of pre-defined keys. So, check near the end of the list.

Rebind keys

SuperUser guide to binding shows an example of using < for left, > for right, and plus for up. This guide also suggested using equal sign for down, although equal sign does have another default binding (“choose buffer”), so there's a conflict. As a result, presumably that isn't avaiable unless unbinding is performed first. The web page also seems to suggest moving left and right to resize by three, which is not a factor of 80 (which is a common screen size) or 79 (allowing one vertical bar to split). Choosing a size of one does add more flexibility.

Fix the terminal support

This approach seems most ideal. Unfortunately, there just isn't a single standard approach that is universally supported. So, the precise steps that might need to be taken can vary based on different software that is used. In some cases, simple software incompatibility may mean that there is no solution other than using different software.

As an example that was found to affect Microsoft Windows: PuTTY has problems with Ctrl-arrow keys and tmux. An alternative was to use mintty for MSYS and OpenSSH for MSYS. (Note that mintty is licensed as GPL3+ and MSYS, which is related to MinGW, may use the GPL. Other software mentioned may have difference licensing which may be less restrictive.) (Further details may be provided here at a later time. For now, just know that mintty.exe might not default to searching the current directory for an executable, so specifying ./ssh may be needed.) A test did find such a solution worked: pressing the command prefix (Ctrl-B) and then the Ctrl-arrow keys did work as desired.

If there is a pane that looks particularly useful, and you wish to un-split the pane, then press the command prefix (generally Ctrl-B), followed by an exclamation point (“!”) to move that pane into its own separate full-size window. (However, Another tmux guide indicated the + key is used. Hawk Host Blog: Tmux: The terminal Multiplexer (Part 2) suggested typing out the command. So it seems likely that this key binding might not have been widely implemeted as early as some others.) That may be reversed with the “join-pane” command.

For some faster layouts, pressing Ctrl-B and then Meta-1 through Meta-5 may work. Remember that on most keyboards, the Alt key corresponds to the Meta key. So, pressing Ctrl-B and then Alt-3 may cause a primary pane to take up most of the screen, while allowing other panes to be available at the bottom of the screen. This way, an informative program (like top) can run in the upper pane, and commands may be typed in a lower pane.

For systems without a well-functioning “Meta” key, and almost-as-good option is to press Ctrl-B followed by the Space bar. The first time that is done, the first layout will be used (similar to pressing Ctrl-B followed by Meta-1). The second time that is done, the second pre-built layout will be used (similar to pressing Ctrl-B followed by Meta-2). Similarly, continuing to use Ctrl-B and then Space bar will keep cycling through the layouts.

While discussing options that use the Meta key, pane resizing might be easiest to do by pressing Ctrl-B and then holding Meta and pressing an arrow key.

Advanced pane handling
join-pane

Advanced usage: The “join-pane” command is a bit tricky. Plan to move a pane (which is a section of a window or, if the window has no sections, the entire window). Make that pane active. Then press Ctrl-B followed by :join-pane -t:+1 (and press Enter). In this example, the “destination” window is the next window, because the window name given was +1. The destination window will be split, which creates a new pane. Then, the current (“src”) pane will get moved into the new location that was made by splitting the destination window.

Note that during some basic experimentation, this was found to work fine. However, later, the tmux server crashed (destroying all the programs in the current session as well as other sessions that involved the same username). So, experiment at your own risk. (This was with OpenBSD 5.2.)

linkw

e.g.: Ctrl-B :linkw (followed by the enter key) : duplicates a window. By default, the current window will be the “src-window” that gets copied. By default, the destination window will be a newly created window.

linkw -t:+3

Misc
tmux
Pane swapping

If there are multiple panes on the screen, each pane has its own terminal. The user may specify to change which terminal is visible in a pane.

Panes may also be swapped using Ctrl-B and then a curly brace (either “{” or “}”).

Ctrl-B Ctrl-O may swap multiple windows. This allows programs to “rotate” around the panes in a current window.

Useful commands: Ctrl-B :list-commands , Ctrl-B :list-keys , Ctrl-B :info , Ctrl-B t (shows a clock in ASCII art)

resizing a window

First, it should be pointed out that many people may think they want to resize a “window” when what is really desired is to resize a “pane”.

Options that may be related include the following, each of which is designed to be typed after pressing the command prefix (Ctrl-B).

:showw
:setw force-height 20
:showw -g
:setw -g force-height 20

Each of these would affect the $LINES variable. Setting this to a value which is less than the number of lines of the session can result in the session showing a border and unused screen space.

The default value is zero, which means “unlimited”, which seems to mean making the window as large as the session.

screen

(No further notes are here at this time.)

Renaming a pane/window
screen

Then, press the command prefix (generally Ctrl-A) followed by A (that's a capital A, so after Ctrl-A, hold Shift and press the a key again). Then press backspace repeatedly to delete the characters from the window's current name, and type the desired name.

tmux

This can be done manually using renamew

See also: man page “NAMES AND TITLES” section, set-titles.

This can also be done with a terminal sequence involving “\033” (as the terminal sequence is described by the man page in multiple places). To avoid malicious behavior, this can be turned off using “setw allow-rename off” (according to the man page). Another command related to renaming is “setw automatic-rename off”.

On a somewhat related note, “set set-titles on” and/or “set set-titles-string customString” may be used to set a program's title bar within an xterm session.