How do I output 256 or even 24-bit colours in Git Bash?
I'm running Git Bash on Windows 10 Creators Update build 15063. During the installation of Git for Windows I chose to Use Windows' default console window instead of MinTTY.
The default console window means cmd.exe, also known as the Command Prompt or Command Processor. Since build 14931 of Windows 10 cmd.exe supports 24-bit colour.
How can I 'unlock' the new 24-bit colour support in Windows 10 Creators Update for Git Bash?
Since cmd.exe also supports ANSI escape codes now, I tested 24-bit colour support in cmd.exe (not Git Bash) using the following command:
echo ^[[48;2;0;191;243m^[[38;2;255;255;255m Ask Question ^[[0m
(The character sequence ^[
are actually the visual representation of the escape control character, which I entered using Ctrl+[.)
I tested 24-bit colour support as well as 'normal' 8-colour support in Git Bash using the commands below. Git Bash only outputs colours when using the basic (non-extended) ANSI escape codes.
echo -e "\033[48;2;0;191;243m\033[38;2;255;255;255m Ask Question \033[0m"
echo -e "\033[44m\033[37m Ask Question \033[0m"
Changing the value of the TERM
environment variable from cygwin
to xterm-256color
did not fix it.
Solution 1:
Upgrading Git Bash should allow it to work. If you run:
echo -e "\033[48;2;0;191;243m\033[38;2;255;255;255m Ask Question \033[0m"
It will return the corresponding color. Here is what the output text will look like:
To update Git Bash, just download it from the link. The installer should be able to detect that you already have Git Bash installed and it just needs to update.