I use gnome-terminal on Ubuntu / Fedora. For color schemes I use base16-shell, along with its corresponding settings for my editor vi.

I have configured my .bashrc to set the base16 theme on start up. I sometimes switch between themes by changing this bashrc file. This works for occasional changes to my color scheme, as I can just my .bashrc once in a while and all future windows open with the correct color.

What I want?

I want to be able to change color scheme on all open gnome-terminal windows with a single click / command. Is there a way to do that?

About my Workflow

I usually have a bunch of terminal windows open with different settings on them. Some of them have text editors open, and some text editor program (vim) in the background, to allow multi-tasking with multiple text editors on the same terminal window. Depending on the lighting in the room, I feel it is better to switch between two color schemes - A light color scheme during the day / brightly lit room, and dark color scheme during the night, not so well lit room.

I don't want to go and type a command to switch color schemes on each open terminal windows. Besides some may have a program running in the foreground printing, which I may not want to interrupt. Is there a way to "signal" the terminal to switch to a custom color scheme?

I understand it might be difficult to do it on terminals that have a program running actively in the foreground. But at least can I do it for all other terminals which have programs in the background, or no command running.

I am willing to explore other terminals if that would help. I have been thinking of using gnome-terminal profiles, but can't seem to figure out how to achieve exactly what I want.

Thanks in advance!

1 Answer 1


GNOME Terminal's settings, like most GNOME apps, is stored in the dconf database. You can use the commands dconf or a higher level alternative gsettings to query or alter the settings.

GNOME Terminal supports multiple profiles. You can't tell it to switch profile on all existing windows, however, you can redefine a profile's property at any time.

The terminal automatically picks up changes to the underlying database immediately.

Dump the database e.g. with dconf dump / > outputfile, change some values in GNOME Terminal's Preferences dialog, then repeat the previous command and compare the two outputs to locate the differences.

You can programatically change the values with commands like:

dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/background-color "'rgb(200,210,220)'"

and similarly for the foreground-color, palette fields.

The more standard #rrggbb notation also works.

Note the nested quotes, the shell strips off the outer ones, whereas the actual value that you set also needs to contain quotes.

If you use a non-default profile then the profile's ID will be different for you.

Another possible approach:

The OSC 4, 10, 11 escape sequences allow you to redefine the colors runtime. These take predecence over the terminal's settings, at least in case of GNOME Terminal.

Iterate through all the entries under /dev/pts, and emit these escape sequence to all of these. E.g.:

printf '\e]11;#abcdef\e\\' > /dev/pts/17

Some of these entries belong to other users, you'll get permission denied for them. Some belong to other terminals, which may not recognize these sequence.

Note that there's a chance that the ongoing activity in the terminal is in the middle of a multibyte UTF-8 sequence or an escape sequence, and you interleave with that. In that case you'll see broken output from the app that's running inside.

I'd recommend this method for those whose terminal supports these OSC sequences, but doesn't allow runtime modification of the settings via other, safer means.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .