tmux uses an alternate screen buffer which is the same height and width as the parent terminal.
In all of the below code examples,
<prefix> refers to the
tmux prefix key combination. It is typically
Ctrl-B by default, although it can vary from system to system.
Installing From Source
This example uses libevent
v6.1 and tmux
v3.0a, but feel free to change the versions as long as they remain compatible with one another.
Then install tmux:
If you get the error
configure: error: "libevent not found" after running the tmux
./configure step, make sure you have install
libevent as per the above instructions.
If you get the error:
/usr/local/bin/tmux: error while loading shared libraries: libevent-X.X.so.X: cannot open shared object file: No such file or directory, you might need to run the below command before you can run
tmux source code can be found at https://github.com/tmux/tmux.
Post-Installation Protocol Version Mismatch
After installation, you might get a
protocol version mismatch error when trying to start
tmux, similar to the below example:
This occurs when there is a older version of the
tmux server left running while you upgrade, and you are trying to connect to it post-upgrade with a newer
tmux client. If you don’t care about losing your existing
tmux sessions, you can use
killall to remove the server process and start afresh:
Create And Attach To Sessions
To create and attach to a new, named tmux session, enter the following at the command prompt:
To attach to an already created named session:
Detach From A Session
To detach from a
tmux session press:
while in the session. This will leave the session running in the background, so you can re-attach to it later.
Increase Scrollback Buffer Size
Add the following line to your
~/.tmux.conf file. This will allow you to retain more data (history) in the
tmux scrollback buffer.
Assign Key To Clear History
Add the following line to your
~/.tmux.conf file. This will allow you to press
Ctrl-l to clear both the scrollback history and screen data at the same time.
This will emulate similar behaviour to pressing
Ctrl-K in bash.
kill-session to kill/delete a tmux session:
tmux supports windows to allow multiple terminals per
tmux session. These windows are also commonly called tabs, but they do not have visible tab UI element in the terminal.
tmux window keys (all of these have to be preceeded with the prefix key, which by default is
How To Prevent tmux From Renaming The Window
Renaming windows is great for organisation once you have more than one or two in use at the same time. However,
tmux can annoyingly decide it wants to automatically rename your windows based on the current
$PROMPT_COMMAND. To prevent this from happening, add the following to your
Swapping/Moving Windows In The Same Session
The easiest way IMHO is to add the following to your
This will allow you to press
Ctrl-Shift-Right to move the currently active tmux window left and right (i.e. swapping positions with the neighbouring windows).
Moving Windows Between Sessions
tmux allows you to move windows between different sessions with the
You have to move the window to a free
window_id (i.e., not one in use).
Re-ordering tmux Sessions
Unlike windows which can be arbitrarily re-ordered,
tmux always orders sessions alphabetically by name. The best solution if you are looking to order sessions is to prefix them with sequential numeral/characters (e.g.
You can rename your current session from within
tmux by typing:
Enter a new name, and press
Reloading The tmux Config File
From within a tmux session:
or from your shell:
This work is licensed under a Creative Commons Attribution 4.0 International License .
- operating systems