Home Terminal Tuts How to scroll up and down in Tmux

How to scroll up and down in Tmux

by Abraham
scroll up and down in tmux

Do you know how to scroll up and down using your Tmux application? This has been a significant concern for those getting started with this application. When I started using this app, I had similar complications, and I did not know how to scroll up and down on Tmux.

This was because it runs multiple windows simultaneously hence becoming more complex to scroll up and down. However, after a lengthy hassle and tussle, I learned how to scroll in Tmux. Therefore, if you have been experiencing the same problems, I will illustrate how to scroll in Tmux.

Tmux is a top-notch open-source terminal/shell multiplexer for Unix-based operating systems, derived from the word “terminal multiplexer.” Tmux is a program that lets you use multiple terminals simultaneously from a single application window. It comes in handy when running multiple command-line scripts or programs at once.

Below are some methods you can apply to enable Tmux scrolling:

Enabling Tmux’s scroll mode

In Tmux, you can scroll up and down by using the following methods:

Press the Ctrl + B keys, then the subsequent “[]” key. To navigate the Tmux interface, use the standard keyboard navigation keys such as up/down arrows, page up/page down, etc.

When a user has finished scrolling, he can exit Tmux’s scroll mode by pressing the Q key. If none of the provided options works for you, try using the F7 key to jump into the scroll mode and q to exit the mode.

1. Use the VI mode

When an associated client controls Tmux, it is referred to as a VI mode in Tmux. Shift + K and Shift + J keys can be used in the VI mode to move line by line in the Tmux interface (if scroll mode is enabled); otherwise, the cursor will only move when the indicated keys are pressed. In the Tmux application, you may also use the C-B (twice) keys to scroll up a page and the C-F keys to scroll down a page.

Enable and employ the copy mode

Press the Ctrl + B keys, then the PgUp key.

Now the terminal will move one page higher in Tmux.

Alter the Tmux.config file

There are instances whereby the provided solutions will be insufficient; in such instances, altering the Tmux.config file may resolve the issue (as discussed below). You may open the Tmux.config file in the terminal by typing the script below:

vim ~/.tmux.config.

Activate mouse scrolling

Follow the steps provided herein to activate mouse scrolling:

Step 1: Add the following lines to the Tmux.config files, depending on your Tmux version:

For the Tmux version below, 2.1

set -g mode-mouse on

For the Tmux version 2.1 and up

set -g mouse on

Step 2: Check to ascertain that the mouse scrolling feature works flawlessly.

Remember that you may leave the scroll mode by pressing the Q key. Additionally, you might opt to copy the contents of the terminal by pressing Shift + Mouse Left Click.

Activate mouse scrolling with key binding

Step 1: To the Config file, append the following lines:

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"

Step 2: Now, terminate the Tmux processes by performing the following:

tmux kill-server && tmux

Step 3: Run Tmux and verify that the scrolling works as expected.

If you need to copy an item while in Tmux’s mouse mode, use “Shift + left mouse click.”

If it doesn’t work, see if appending the following to Tmux.config fixes the issue:

set -g mouse on

bind -n WheelUpPane {

if -F '#{==:#{window_name},nvim}' {

send-keys -M

} {

copy-mode -e

}

}

Activate default Xterm scrolling

Modify the Tmux.config file as follows:

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

Now verify that the Tmux scroll meets your expectations.

If it does not work, attempt the following: add to Tmux’s configuration file the line of code below (you may need to reboot your machine afterwards):

set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"

However, if you switch the terminal type to Putty, the preceding code may not function; if you must use Putty, you may add the following to Tmux’s configuration file:

set -g terminal-overrides "putty*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"

If this does not address the problem, you may consider adding the following to the configuration file:

set -ga terminal-overrides ',xterm*:smcup@:rmcup@'

Below is a list of the short key bindings you can use to scroll up and down in Tmux.

FunctionViEmacs
Half-page downC-uM-Down
Half-page upC-uM-Up
Search forward/C-s
Next pageC-fPage down
Search backwards?C-r
Previous pageC-bPage up
Scroll upC-Up or C-yC-Up
Scroll downC-Down or C-e C-Down
Search againnn
Search again in reverse modeNN
---------------

Note: Scrolling with keys is primarily enabled on Tmux. Therefore, you should always use this method before trying other alternatives provided in this article guide.

We hope you enjoyed reading this article guide. If you need clarification, let us know via the comments section, and we will be glad to help.

You may also like

3 comments

Dilson September 19, 2022 - 1:24 PM

the correct tmux conf file is: ~/.tmux.conf
and not ~/.tmux.config

Reply
crazyoptimist October 13, 2022 - 11:51 PM

Thanks man!
`C-b [` worked for me, not even subsequent `[]`

Reply
Emily February 4, 2023 - 2:17 PM

what does subsequent ‘[]’ mean?

Reply

Leave a Reply to Dilson Cancel Reply

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.