Skip to content

Instantly share code, notes, and snippets.

@keithkim
Created January 20, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithkim/ce5c21445c7c3791bd2740c160496fab to your computer and use it in GitHub Desktop.
Save keithkim/ce5c21445c7c3791bd2740c160496fab to your computer and use it in GitHub Desktop.
Colors in cmd console or batch file for Windows
REM ### credit: https://stackoverflow.com/users/4544905/nick-n-chicago
REM ### from: https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line/8920789
@echo off
cls && color 08
rem .... the following line creates a [DEL] [ASCII 8] [Backspace] character to use later
rem .... All this to remove [:]
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (set "DEL=%%a")
echo.
<nul set /p="("
call :PainText 09 "BLUE is cold" && <nul set /p=") ("
call :PainText 02 "GREEN is earth" && <nul set /p=") ("
call :PainText F0 "BLACK is night" && <nul set /p=")"
echo.
<nul set /p="("
call :PainText 04 "RED is blood" && <nul set /p=") ("
call :PainText 0e "YELLOW is pee" && <nul set /p=") ("
call :PainText 0F "WHITE all colors"&& <nul set /p=")"
goto :end
:PainText
<nul set /p "=%DEL%" > "%~2"
findstr /v /a:%1 /R "+" "%~2" nul
del "%~2" > nul
goto :eof
:end
echo.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment