From the manpage: tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux is a handy way to keep sessions active. It allows you to attach and detach from a running session ensuring your activity will remain even when you are logged out. To start tmux simply enter the command:
tmux
By default tmux uses the key combination <CTL>+b followed by different keys for a command. For a full list of available commands users can use:
man tmux
Viewing available sessions
You can view all your active tmux sessions by issuing the tmux ls command.
tmux ls
Attaching to a session
To reattach to the last session you ran simply use the command:tmux attach
To attach to a different session you can do:
tmux attach -t $SESSIONNAME
Detach from current session
After starting tmux, you can start your long-running job. Then you can leave your tmux session running with your job inside it by detaching from your tmux session. To detach issue control-b and then hit the "d" key.
<CTL>+b d
Split Terminal Vertically
Tmux allows you to have several terminal instances at once on a single screen. You can split a single pane into multiple panels. To split vertifically you can use control-b followed by the % key.
<CTL>+b %
Split Terminally Horizontally
To split a tmux session horizontally it is control-b followed by the " key.
<CTL>+b "
Switching between Panes
You can easily switch between different split panes by using the control+b combination followed by an arrow key in the direction you want to be moving.
<CTL>+b <UP>
<CTL>+b <DOWN>
<CTL>+b <LEFT>
<CTL>+b <RIGHT>
Creating a new Window
You can create multiple windows at a time and cycle through them. To create a new window use the key combination control-b followed by the c key.
<CTL>+b c
Cycling Between Windows
You can cycle between your windows. This is useful for running commands in different panes. To cycle between all active windows issue the control+b key sequence followed by w.
<CTL>+b w
Cycling Between Sessions
You can also opt to cycle between active sessions. This can be done using control-b followed the s key.
<CTL>+b s
Scrolling
Tmux allows users to scroll back in their input buffer to see a fair amount of history. This can be done using control-b followed by [ key.
<CTL>+b [
You can use the arrow keys to navigate the scrollback buffer.
Copying to Tmux's Buffer
You can copy and paste using Tmux's internal buffer. First go into scrolling mode:
<CTL>+b [
You can select text by pressing control-spacebar.
<CTL>+<SPACEBAR>
To yank the text it's the alt key and w.
<ALT>+w
To paste from tmux's buffer use control+b ]
<CTL>+b ]
Making Changes to Tmux
Tmux is highly configurable. You can change key combinations, terminal colors and behavior. To make changes to tmux create and/or edit the .tmux.conf file located in your home directory. Note the leading ., which indicates this is a hidden file and will not show up by default. You can view hidden files with:
ls -a
A good example of a modified .tmux.conf can be found here: https://willhbr.net/2024/03/06/tmux-conf-with-commentary/