Search code examples
git-bashwindows-terminal

Set git bash color scheme via script in Windows Terminal


To set my terminal theme, I typically use a script which prints ANSI control sequences. For example,

echo -e "\033]11;rgb:20/20/30\033\\"

sets the background color to RBG #202030. This works with git-bash+mintty, and it works with WSL+Windows Terminal. Unfortunately, it does not work with git-bash+Windows Terminal. Instead, it just outputs a \ with no change to the color scheme.

Does anyone have ideas for troubleshooting this?

A couple things I've tried:

  • Try to output colored text, e.g., echo -e "\033[44m\033[37m Test \033[0m". This works just fine.
  • Check the $TERM environment variable. It is equal to xterm-256color, just the same as in WSL (which works).

In case it matters, here's the command setting I'm using in Windows Terminal to launch git bash:

"commandline": "C:/Program Files/Git/usr/bin/bash.exe -i -l",

Solution

  • Your issue seems local to your environment. Ensure you are using the latest version of Windows Terminal and git bash and perhaps reinstall them. I am an running Windows Terminal 1.0.1401.0 and git bash installer 2.27.0 (installed with no PATH modifications and no expiremental settings) and I can change the background of the terminal in Windows Terminal using the command: echo -e "\033]11;rgb:20/20/30\033\\.