Terminal multiplexers allow us to run multiple terminal screens within one terminal window or tab. One popular terminal multiplexer is tmux and is used with Linux-based systems.
The terminal widget below demonstrates how tmux works:
An important use of tmux is establishing multiple SSH connections. We could leave active connections open and attach to them later whenever we require.
Scrolling in tmux can be a bit of a hassle, especially when running applications that don't release the command line interface control back to the user. In tmux, simple scrolling isn't allowed, such as using the scroll gestures on a trackpad or using a mouse wheel within a terminal window. Thankfully, tmux allows multiple ways to enable scrolling. We will explore navigating a tmux screen in its copy mode.
We can activate copy mode in tmux by pressing the "Ctrl" (or "control" for Mac users) and "b" (or "B") key, followed by the "[" key. Now we can navigate the tmux screens using the following ways:
Press the up, down, left, and right arrow keys on the keyboard. The up and down arrow keys take us to the next line in their direction, and the left and right keys take us to the next character.
Press the "PgUp" and "PgDn" keys—alternatively known as the "Page Up" and "Page Down" keys, respectively—to move up or down a page.
Note: Mac users can press the "option" key with the up arrow key for Page Up and the "option" key with the down arrow key for Page Down.
Press the "g" (or "G") key and enter a line number; tmux will take us to that line.
Try this out in the below terminal window where tmux runs two applications on the multiplexed terminal screen:
Free Resources