I want to set a property in VS Code settings such that it conditions on the system's preferred color theme.
VS Code allows you to detect color scheme by setting workbench.autoDetectColorScheme
to true
. Then you can set color themes for the properties - workbench.preferredLightColorTheme
and
workbench.preferredDarkColorTheme
.
Is there any way to set properties like terminal.background
such that they change along with the workbench color theme?
CodePudding user response:
Following @rioV8's suggestion I was able to solve this as follows:
{
"window.autoDetectColorScheme": true,
"workbench.preferredLightColorTheme": "Small Aperture",
"workbench.preferredDarkColorTheme": "Large Aperture",
"workbench.colorCustomizations": {
"[Small Aperture]": {
"terminal.background": "#F2F7F2",
//...
},
"[Large Aperture]": {
"terminal.background": "#141414",
//...
},
},
}
Similar to a CSS media query, you can set different properties for different color themes by using their name inside square brackets.
Unfortunately, you'll have to add sections for all the themes you regularly use.