Skip to content

Instantly share code, notes, and snippets.

@nptit
Last active March 30, 2017 08:20
Show Gist options
  • Save nptit/feb25fa9c53d2c3812d640e47c7050a1 to your computer and use it in GitHub Desktop.
Save nptit/feb25fa9c53d2c3812d640e47c7050a1 to your computer and use it in GitHub Desktop.
Colored output in windows batch files https://git.io/matrix
@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
set backgroundcolor=0
set /a i=0
:startloop
set "color=%backgroundcolor%%i%"
sleep 0.1
call :writeLn %color% "The Matrix has you"
if /i "%i%" geq "9" (
set /a i=1
) else (
set /a i+=1
)
goto :startloop
exit /b
:write
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
exit /b
:writeLn
call :write %1 "%~2"
echo:
exit /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment