~/.config/konsolerc. Specifically, edit the <General> section to set the NumberOfHistoryLines key to your desired integer value. This method bypasses the graphical interface and allows for scriptable, automated terminal configuration management on Linux systems.
Understanding Konsole Configuration Structure
Konsole stores its user-specific settings in a plain text INI-style configuration file rather than using environment variables or registry entries. This file is typically found in the XDG config directory within your home folder. The structure is hierarchical, with sections denoted by bracketed headers like[General] or [Appearance].
The specific setting that controls how many lines of history are retained is stored under the <General> section. By default, this value might be set to 1000 or another standard number. When you adjust this value programmatically, you are directly editing the persistent state of the application. It is important to note that these changes do not take effect immediately in currently open sessions; they apply when Konsole is restarted or a new window is opened.
For users managing multiple machines or deploying standardized environments, understanding this file structure is crucial. Unlike some other terminals that rely on shell-level variables, Konsole’s scrollback is an application-level constraint. Therefore, manipulating it requires direct file manipulation or specialized tools that parse the KDE configuration format.
Manual Editing Method
The most reliable way to ensure the correct syntax is used is to manually edit the configuration file using a command-line text editor such asnano, vim, or sed. You can open the file directly from your bash prompt.
Use the following command to open the configuration file:
nano ~/.config/konsolerc
Once the file is open, locate the line that begins with NumberOfHistoryLines=. If this line does not exist, you may need to add it under the [General] header. Change the value after the equals sign to your preferred number of lines. For example, to set a large buffer:
NumberOfHistoryLines=5000
Save the file and exit the editor. To verify the change, close all instances of Konsole and reopen it. You can test the depth of your scrollback by generating a significant amount of output, such as running cat /usr/include/linux/*.h | wc -l or simply scrolling up through previous commands.
If you prefer a non-interactive approach, you can use sed to replace the existing value in one line. Be cautious with regular expressions to avoid unintended replacements. A safe command would look like this:
sed -i 's/^NumberOfHistoryLines=.*/NumberOfHistoryLines=5000/' ~/.config/konsolerc
This command searches for any line starting with NumberOfHistoryLines= and replaces the entire line with the new value. This is particularly useful in shell scripts where interactive editors are not feasible.
Using kwriteconfig5 for Programmatic Changes
Since Konsole is part of the KDE ecosystem, it integrates well with KDE’s configuration utilities. The toolkwriteconfig5 allows you to write configuration values without manually parsing INI files. This reduces the risk of syntax errors and ensures that the configuration is written in the exact format expected by the system.
To update the scrollback limit using this utility, run the following command in your terminal:
kwriteconfig5 --file konsolerc --group General --key NumberOfHistoryLines 5000
Here, --file specifies the target configuration file (konsolerc), --group identifies the section (General), and --key targets the specific parameter (NumberOfHistoryLines). The final argument is the new value. This method is cleaner than raw string replacement because it handles missing keys gracefully and respects the underlying data types.
After executing this command, restart Konsole to apply the changes. This approach is highly recommended for automation scripts because it is less prone to breaking if the configuration file structure changes slightly between updates, provided the key name remains consistent.
Verifying and Troubleshooting
After applying the changes, it is essential to verify that the new limit is active. Open Konsole and generate enough output to exceed your previous limit. Try scrolling up using the mouse wheel or keyboard shortcuts. If you hit the end of the buffer before reaching the oldest command, the setting has not applied correctly. Common issues include:- Cached Settings: Sometimes Konsole caches certain UI states. A full quit (closing all windows) is necessary, not just closing a single tab.
- Profile Overrides: If you are using custom profiles in Konsole, ensure that the profile settings are not overriding the global defaults. Check the profile manager to see if "Number of History Lines" is explicitly set there.
- File Permissions: Ensure that
~/.config/konsolercis writable by your user. If you modified the file as root, ownership issues may prevent the application from reading it correctly.
Frequently Asked Questions
Does changing the scrollback affect performance?
Yes, increasing the scrollback buffer consumes more RAM because the terminal emulator must store more text in memory. Extremely large values (e.g., over 100,000 lines) may cause slight lag during startup or scrolling on systems with limited resources.
Can I set different scrollback limits for different Konsole profiles?
Yes, Konsole allows you to create multiple profiles. Each profile can have its own NumberOfHistoryLines setting. You can switch between profiles via the Tools menu or by launching Konsole with specific profile arguments.
Why doesn't my change take effect immediately?
Konsole reads its configuration file only at startup. Any changes made to konsolerc while the application is running will not be reflected until you completely close all Konsole windows and start a new session.
Is there a way to reset the scrollback to default?
To reset to the default, you can either delete the NumberOfHistoryLines key from the ~/.config/konsolerc file or set it to the factory default value, which is typically 1000. Alternatively, you can reset your entire Konsole configuration by deleting the ~/.config/konsolerc file, though this will remove all other custom settings.
How do I check the current scrollback limit via command line?
You can grep the configuration file to find the current value by running grep NumberOfHistoryLines ~/.config/konsolerc. This will output the current setting, allowing you to verify what is currently configured before making changes.