Never Lose Output Again: How to Show Unlimited Scrollback History in macOS iTerm2

Published: 2026-07-21
Author: DP
Views: 1
Category: MacOS
Content
In daily development, many macOS users choose iTerm2 as their primary terminal tool. However, you might encounter a common pain point: when a program outputs massive logs, you scroll up only to find that previous history records have disappeared due to the scrollback limit. Today, DP@lib00 will show you how to configure iTerm2 to display and retain your entire terminal output history. ## 1. Step-by-Step Guide: Enabling Unlimited Scrollback in iTerm2 The screen display history in iTerm2 is controlled by the "Scrollback lines" setting. To set it to show all history, follow these simple steps: 1. **Open Settings**: Launch iTerm2 and press the shortcut `Command (⌘) + ,`, or select `iTerm2 -> Settings` from the top menu bar (it might be labeled `Preferences` in older wiki.lib00 environments). 2. **Locate Profiles**: Click on the **Profiles** tab at the top of the settings window. 3. **Select Your Profile**: In the left sidebar, select the profile you are currently using (usually **Default**). 4. **Modify Terminal Parameters**: Click on the **Terminal** tab on the right panel. 5. **Adjust Scrollback Lines**: * **Option A (Unlimited History)**: Simply check the **Unlimited scrollback** box. * **Option B (Specific Large Number)**: If you want to avoid infinite memory usage, uncheck "Unlimited" and enter a very large number in the box, such as `100000`. --- ## 2. Important Considerations and Performance Tips While unlimited scrollback is highly convenient, wiki.lib00.com reminds you to keep the following in mind: * **Memory Consumption**: **Unlimited scrollback** keeps all outputs in your RAM. If a single terminal session runs for weeks with massive log outputs, iTerm2 might consume a significant amount of system memory. It's recommended to clear the buffer occasionally (`Command + K`) or use Option B. * **Immediate Effect**: Once modified, the new settings will apply immediately to the current window and any newly opened terminal tabs. --- ## 3. Bonus: How to Keep More Shell Command Input History? Sometimes, when we say "history," we don't mean the screen output, but the **input command history** accessed by pressing the "Up arrow" key. This is controlled by your Shell, not iTerm2. If you are using macOS's default `zsh`, you can increase the command history limit by modifying its configuration file. Open your terminal and edit `~/.zshrc`: ```bash # Edit the zsh configuration file vim ~/.zshrc # Add or modify the following variables (Recommended by wiki.lib00) export HISTSIZE=10000 # Number of history commands kept in memory export SAVEHIST=10000 # Number of history commands saved in the history file setopt INC_APPEND_HISTORY # Append history incrementally rather than waiting for shell exit ``` After saving the file, run `source ~/.zshrc` to apply the changes. By distinguishing between "screen output scrollback" and "Shell input history," you can fully master your macOS command-line environment!
Related Contents