Home > database >  How to change vscode's color theme using the the CLI? (`code` command)
How to change vscode's color theme using the the CLI? (`code` command)

Time:10-14

Is it even possible to change the colour theme using the CLI? I went through the doc but could not find anything that matches this requirement.

I am working on a personal project where I am adding a cron job to switch the theme of my computer.

CodePudding user response:

It's not possible to change settings using the code command, but instead you could use sed to edit settings.json like so:

sed -i -e 's/"workbench.colorTheme": ".*"/"workbench.colorTheme": "Visual Studio Dark"/g' "$HOME/.config/Code/User/settings.json"
  • "workbench.colorTheme": ".*" is the regular expression (regex) to replace.
  • "workbench.colorTheme": "Visual Studio Dark" is the replacement string. Change Visual Studio Dark to your desired theme.
  • $HOME/.config/Code/User/settings.json is the path to your settings.json
  • Related