To increase tmux scrollback buffer size, add set -g history-limit 10000
to your ~/.tmux.conf
file (adjust the number to your desired limit). This setting controls how many lines of output each pane remembers. After adding this line, either restart tmux or reload your configuration with Ctrl+b : source-file ~/.tmux.conf
.
# Add to ~/.tmux.conf set -g history-limit 10000 # Then reload config Ctrl+b :source-file ~/.tmux.conf
The scrollback buffer in tmux determines how many lines of terminal output are retained in memory for each pane. Increasing this limit allows you to scroll back further in your terminal history, which is particularly useful for reviewing log outputs, command results, or long-running processes.
By default, tmux sets the scrollback buffer to 2000 lines per pane. This means each pane can "remember" the last 2000 lines of output. Once this limit is reached, the oldest lines are discarded to make room for new output.
For many use cases, especially when working with verbose logs or compilers, this default limit may be too small. Increasing it allows you to retain more history and reduces the chance of losing important information.
To permanently change the scrollback buffer size, add this line to your ~/.tmux.conf
file:
# Set history limit to 10,000 lines set -g history-limit 10000
You can choose any number based on your needs and available memory. Common values range from 5,000 to 50,000 lines. The -g
flag makes this a global setting that applies to all sessions.
After adding the line to your configuration file, you have two options to apply the change:
source-file ~/.tmux.conf
Note that changing this setting only affects new panes and windows. Existing panes will keep their current history-limit setting until they are closed and reopened.
To check the current scrollback buffer size setting:
# In tmux command mode (Ctrl+b :) show-options -g history-limit
You can also change the scrollback size for the current tmux session only (without modifying your configuration file):
# In tmux command mode (Ctrl+b :) set-option -g history-limit 20000
This setting will remain in effect until you restart the tmux server.
Increasing the scrollback buffer significantly will increase tmux's memory usage. Each line in the scrollback buffer consumes memory, so very large values (100,000+) can lead to high memory consumption, especially if you have many panes open.
As a rough guideline:
To access and navigate through your scrollback buffer:
For exceptionally large output that exceeds even a large scrollback buffer, you can capture the pane contents to a file:
# In tmux command mode (Ctrl+b :) capture-pane -S - save-buffer ~/output.txt # Or from your shell tmux capture-pane -pS - > ~/output.txt
The -S -
option tells tmux to capture from the start of the scrollback buffer.