1

Let's say that something breaks the default 256 colour palette. As an example, pick on colour 108:

printf "\033]4;108;rgb:ff/00/00\033\\"

How do I undo this? I've searched all current "reset terminal" questions, and have tried:

reset # You can't see this in the screenshot as it clears the screen
tput init
tput sgr0
printf '\e[0m'

Using a test pattern we can clearly see that colour #108 is still b0rken:

Colour 108 is still broken

I'm running GNOME terminal.

I don't want to do something like gconftool --recursive-unset /apps/gnome-terminal as this will mess with general terminal configuration (eg fonts) for all open/new gnome-terminals. It's too much of a broad brush stroke.

How do I, from the command line within the terminal:

  1. Restore a particular palette colour to its default?
  2. Restore ALL palette colours to their default?

As the issue can be created with emitting a control code, I hope it can be solved with one, too.

3
  • 1
    askubuntu.com/questions/14487/…
    – Zanna
    Commented Sep 11, 2016 at 6:18
  • 1
    that gconftool command only resets gnome-terminal what you mean by all terminals?
    – Anwar
    Commented Sep 11, 2016 at 7:53
  • 1
    Does opening a new terminal tab/window fix it?
    – user423626
    Commented Sep 11, 2016 at 8:31

1 Answer 1

2

Instead of 4, use 104 to reset a particular color, e.g. color number 108 as in your example:

printf "\033]104;108\033\\"

Omit the color number to reset the entire palette (all the 256 colors):

printf "\033]104\033\\"

Note: GNOME Terminal (actually VTE) uses two "levels" for colors. The colors set via VTE's API (or in case of GNOME Terminal, the first 16 colors chosen in the Preferences dialog and stored in gsettings/dconf, the rest are VTE's hardcoded defaults) have lower precedence. For each slot, a possible escape sequence has higher precedence and temporarily overrides this value. The above escape sequence with the "104" parameter "resets", that is clears the value specified via escape sequence "4" and hence reverts to the value specified in GNOME Terminal's preferences dialog (or VTE's default for the extended 256-color palette). Due to this design, there's absolutely no way a gsettings or dconf command could revert the effect of a color changing escape sequence. Other, non VTE based terminal emulators might follow a different approach, or might not support these escape sequences at all.

3
  • Are you sure the sequences are correct? I get: @ravi@boxy:~$ printf "\033]104;108\033\\" ]104;108@ravi@boxy:~$ There is a weird character just before the ]104;108@ in the output.
    – Tom Hale
    Commented Sep 12, 2016 at 4:06
  • The feature was implemented in vte-0.36. If you're using Ubuntu 14.04 then you don't have it yet (although it probably works for you in xterm).
    – egmont
    Commented Sep 12, 2016 at 7:14
  • For 14.04 you can try to install vte3-0.36.3 as found at launchpad.net/~gnome3-team/+archive/ubuntu/gnome3-staging/…. It'll bring quite a few new features (e.g. rewrap on resize) along with this one. (Don't go for 0.38 or newer, they're not compatible.)
    – egmont
    Commented Sep 12, 2016 at 7:31

You must log in to answer this question.

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