0

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",
Nick
  • 167
  • 2
  • 12

2 Answers2

1

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\\.

apena
  • 2,091
  • 12
  • 19
  • 1
    Thank you @apena! Upgrading to git 2.27.0 (from 2.1x, I believe) fixed the problem :) – Nick Jun 17 '20 at 17:33
0

I suggest using a custom color scheme in settings.json for Windows Terminal as it's persistant and fully customizable using hex color codes.

In settings.json:

  1. After your line "commandline": "C:/Program Files/Git/usr/bin/bash.exe -i -l", add a new property: "colorScheme": "Nicks",. If it is the last property in the object then remove the comma.
  2. After the entire profiles property add a schemes property with an object something like this:
    "schemes": [
        {
            "name" : "Nicks",
            "background" : "#202030",
            "black" : "#282C34",
            "blue" : "#61AFEF",
            "brightBlack" : "#7FB323",
            "brightBlue" : "#00AFEF",
            "brightCyan" : "#56B6C2",
            "brightGreen" : "#AAD76F",
            "brightPurple" : "#CEE066",
            "brightRed" : "#FC7474",
            "brightWhite" : "#DCE4DF",
            "brightYellow" : "#22F901",
            "cyan" : "#70E8F8",
            "foreground" : "#CAE0AC",
            "green" : "#6A8854",
            "purple" : "#C678DD",
            "red" : "#FB4242",
            "white" : "#DCDFE4",
            "yellow" : "#E5C07B"
        }
    ],

If schemes is the last property in the object then remove the comma.

Save the file and the changes should take effect instantly without having to reload the shell.

apena
  • 2,091
  • 12
  • 19
  • Thanks @apena. I realize that I can set up themes within the Windows Terminal settings, but I prefer to use theme shell scripts (as described in the original question) because they are independent of the particular terminal emulator being used and thus more portable. They work on any terminal emulator that supports ANSI control sequences. Windows Terminal clearly has such support (as it works with WSL), but there's something about the combination of git-bash and Windows Terminal that's not working right. – Nick Jun 17 '20 at 08:50
  • Thank you for the clarification. In an attempt ot help you troubleshoot this, I Installed git bash 2.27.0 and made a profile for it in Windows Terminal (version: 1.0.1401.0), opened git bash in a tab and I could change the background with the command: `echo -e "\033]11;rgb:20/20/30\033\\"`. So your issue is most likley local to your specific environment. – apena Jun 17 '20 at 16:46