MacBook Pro Terminal – Changing X11/Xquartz Colour Setting to 256 colors

macmacbook promacosterminalx11

I want to change X11 color settings from 'From Display'(default) to '256 colors' using Terminal.app. I already know how to change it using the GUI, but I need a bash script to do it. I have:

  • Mavericks 10.9.5
  • XQuartz 2.7.7 (xorg-server 1.15.2)
  • MacbookPro

Best Answer

The command to change Color: From Display, as shown in X11 Preferences of XQuartz, to
Color: 256 Colors, from the command line in Terminal is:

defaults write org.macosforge.xquartz.X11 depth -int 8
  • Note: XQuartz should be closed when making this change or the ones below, from the command line or from within a bash script.

To reset it to the default, Color: From Display, use the following:

defaults delete org.macosforge.xquartz.X11 depth

Or:

defaults write org.macosforge.xquartz.X11 depth -int -1
  • Note: By default the depth key doesn't exist however, when reset from the GUI to the default, the setting is -1, although either is acceptable to set the default back to Color: From Display.