To enable unlimited scrollback with iTerm2, you can adjust the scrollback settings within iTerm2 preferences. Here's how you can do it:
Open iTerm2 Preferences: Launch iTerm2 if it's not already open. Then, go to the "iTerm2" menu at the top-left corner of the screen and select "Preferences..." Alternatively, you can use the keyboard shortcut Cmd + , to open preferences.
Navigate to Profiles: In the Preferences window, click on the "Profiles" tab at the top.
Select a Profile: Choose the profile you want to modify from the list on the left-hand side. If you're using the default profile, it might be named "Default".
Adjust Scrollback Settings:
Within the "Profiles" tab, click on the "Terminal" tab under the
selected profile.
Scroll down until you see the "Scrollback Buffer" section.
You can adjust the "Scrollback lines" slider to set a
maximum number of lines if you don't want to use unlimited
scrollback.
Optionally Check the checkbox next to "Unlimited scrollback".
Apply Changes: Once you've adjusted the scrollback settings to your preference, close the Preferences window. The changes should take effect immediately.