Instantly share code, notes, and snippets.

Embed
What would you like to do?
ANSI Colors in standard Windows 10 shell
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
echo ^<ESC^>[31m Red
echo ^<ESC^>[32m Green
echo ^<ESC^>[33m Yellow
echo ^<ESC^>[34m Blue
echo ^<ESC^>[35m Magenta
echo ^<ESC^>[36m Cyan
echo ^<ESC^>[37m White
echo.
echo  NORMAL BACKGROUND COLORS 
echo ^<ESC^>[40m Black
echo ^<ESC^>[41m Red
echo ^<ESC^>[42m Green
echo ^<ESC^>[43m Yellow
echo ^<ESC^>[44m Blue
echo ^<ESC^>[45m Magenta
echo ^<ESC^>[46m Cyan
echo ^<ESC^>[47m White (white)
echo.
echo  STRONG FOREGROUND COLORS 
echo ^<ESC^>[90m White
echo ^<ESC^>[91m Red
echo ^<ESC^>[92m Green
echo ^<ESC^>[93m Yellow
echo ^<ESC^>[94m Blue
echo ^<ESC^>[95m Magenta
echo ^<ESC^>[96m Cyan
echo ^<ESC^>[97m White
echo.
echo  STRONG BACKGROUND COLORS 
echo ^<ESC^>[100m Black
echo ^<ESC^>[101m Red
echo ^<ESC^>[102m Green
echo ^<ESC^>[103m Yellow
echo ^<ESC^>[104m Blue
echo ^<ESC^>[105m Magenta
echo ^<ESC^>[106m Cyan
echo ^<ESC^>[107m White
echo.
echo  COMBINATIONS 
echo ^<ESC^>[31m red foreground color
echo ^<ESC^>[7m inverse foreground ^<-^> background
echo ^<ESC^>[7;31m inverse red foreground color
echo ^<ESC^>[7m and nested ^<ESC^>[31m before nested
echo ^<ESC^>[31m and nested ^<ESC^>[7m before nested
@mlocati

This comment has been minimized.

Copy link
Owner Author

mlocati commented Jun 15, 2016

Output:

output

PS: Download the raw file: it contains the escape character (hex 1B, dec 27, oct 33).

@Tymski

This comment has been minimized.

Copy link

Tymski commented Jul 16, 2017

Cool

@rourke

This comment has been minimized.

Copy link

rourke commented Dec 13, 2017

@mlocati Thanks for this! However it doesn't work in a for loop:

image

Do you know how to solve this?

@AndyK70

This comment has been minimized.

Copy link

AndyK70 commented Jan 9, 2018

@rourke it works in a loop, try
grafik

But if you put in timeout it works only for the first loop pass. Maybe there is something about this command which breaks the coloring codes:
grafik

If you go with pause it works:
grafik

if you only want the time delay but no user interaction you should go with the oldstyle ping:
grafik

@MG-Tech

This comment has been minimized.

@xuanchuong

This comment has been minimized.

Copy link

xuanchuong commented Dec 28, 2018

very nice (y)

@T0MuX

This comment has been minimized.

Copy link

T0MuX commented Feb 1, 2019

Not working for me too. Win7 SP1 NT6.1.7601.
I type directly thoses commands in cmd.exe it even no copying right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment