How do I get colorized output on my windows git-bash terminal?

Use winpty

Windows Git Bash has some documented quirks: Winpty and Git Bash

$ winpty npm start
winpty: error: cannot start 'npm': Not found in PATH

Again another windows / git bash quirk, it doesn't attempt to resolve executables ending in .cmd so it needs a nudge.

$ winpty npm.cmd start

The same applies for yarn with:

winpty yarn.cmd start

While we are here and you are having trouble getting gyp to locate your Python2 install location to compile native extensions then try this:

env PYTHON=/c/Python27/ winpty yarn.cmd install

Git Bash overrides your PYTHON environment variable for only the duration of this command. You get winpty to run the pseudo-tty session to allow animation rendering and coloring.

Assuming your python 2 install location is C:\Python27


For me, it was choosing Windows default console window instead of MinTTY that made color output not working.

My solution:

  1. Uninstall git bash; during installing, choose MinTTY (the default option).
  2. After installation, head over to C:\Program Files\Git\etc, open your git bash
  3. vim ~/.bashrc (for some reason using an editor doesn't work; I guess it's a privilege issue)
  4. Under # Add colors to 'ls' change it to alias ls='ls --color=auto'

Then restart and it should work.

My version: git version 2.24.1.windows.2


Uninstall Git Bash for Windows 10 and run the installer again:

  • Click next until you'll prompt to choose to Configure the terminal emulator to use with Git Bash, here you select Use Windows default console window (instead of the default option which use MinTTY as terminal emulator)
  • Click next and finish the installation

Test if it works correctly:

  • Open Git Bash (cmd will open up), try to use ls you'll see all folder colored in blue
  • Try some ANSI escape code by running echo -e "\033[44m\033[37m Test \033[0m" you'll se the text Test with a blue background as seen in the screenshot below

enter image description here

Windows 10 Console support 24-bit color and ANSI escape sequences


The terminal was a MinTTY, which does not support colors it seems. Fixed it by re-installing and ticking of Windows Terminal.