This can be done with gsettings
.
Limit scrollback to 250,000 lines:
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/ scrollback-lines 250000
The maximum scrollback-lines
value is 2147483647
, and the default is 10000
.
Enable unlimited scrollback:
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \')/ scrollback-unlimited true
How it works:
gsettings offers a simple commandline interface to GSettings. It lets
you get, set or monitor an individual key for changes.
The SCHEMA and KEY arguments are required for most commands to specify
the schema id and the name of the key to operate on. The schema id may
optionally have a :PATH suffix. Specifying the path is only needed if
the schema does not have a fixed path.
When setting a key, you also need specify a VALUE The format for the
value is that of a serialized GVariant, so e.g. a string must include
explicit quotes: "'foo'". This format is also used when printing out
values.
We are using org.gnome.Terminal.Legacy.Profile
as SCHEMA
.
The :PATH
we need is /org/gnome/terminal/legacy/profiles:/:[target-profile-id]/
where [target-profile-id]
is the id of the profile we are editing. The command gsettings get org.gnome.Terminal.ProfilesList default
gets the id of the default profile and tr -d \'
removes the '
from the response.
To change terminal scrollback lines, the KEY
is scrollback-lines
and we set its VALUE
to 250000
, which is the number of lines we want to be able to scroll back. Depending on whether we want to enable or disable the unlimited scrollback, we use scrollback-unlimited
as KEY
with true
or false
as VALUE
.
Related:
If you are worried about resource usage, check this post: Gnome terminal scrollback lines?
dconf write /org/gnome/terminal/legacy/.../key value
to set that key and anotherdconf reset /org/gnome/terminal/legacy/.../key
to reset ... Only if gnome-terminal developers had provided a cleaner way to get the current profile's name ... +1 – Raffa Nov 13 '23 at 15:49default
profile isn’t workable in e.g.dconf
… things seem to break when you get to that point in the path and you need to substitutedefault
with the ID … Wouldn’t it be much easier to be able to simply do something likedconf write /org/gnome/terminal/legacy/profiles/default/scrollback-lines 250000
wheredefault
actually resolves to the default profile … Or something in these lines. – Raffa Nov 13 '23 at 18:46gnome-terminal
used to have an option—save-config
snd that could be used to get the current profile's ID but now it’s removed in newer versions … and of course I agree that most users might not need such a thing, but extra options are always a plus – Raffa Nov 13 '23 at 18:53gnome-terminal
is a great app nonetheless. – Raffa Nov 13 '23 at 19:11tr
to remove the quotes from the id. You are absolutely correct in your assumption that I was looking for a non-interactive solution that can be used in automated install procedure, not necessarily running from gnome-terminal. Thank you for your work ongome-terminal
, it's a great app. I understand that developers time is limited. – sotirov Nov 14 '23 at 06:13[]
or''
or,
? How about getting a certain index only from an array? ... – egmont Nov 14 '23 at 11:36tr
is too much of inconvenience, then either adding one single new cmdline option for your particular use case, or adding hundreds of them for all possible similar use cases, are all wrong approaches, the right approach would be to ask dconf or gsettings developers to add such a command line option into their tools. – egmont Nov 14 '23 at 11:41