Page 1 of 1

Batch coloring not working after git output

Posted: 18 May 2021 01:33
by Bleifuss
Hello!

I'm using GIT and wrote a small helper script.
For better readability I'm using ESCAPE SEQUENCES for coloring.

It works for the first echo line, but after a git command e.g. git staus it's not working anymore.

My git_helper.at

Code: Select all

	echo <ESC>[35mThis line is in color mode, it works!<ESC>[0m
	git status
	echo <ESC>[35mThis line not, it shows only crypted char<ESC>[0m
It works with other programms than GIT, but that's not I want ;)

So, does somebody has a sugestion?

Thank You.

Re: Batch coloring not working after git output

Posted: 18 May 2021 17:06
by IcarusLives
You're going to need the ESC character instead of whatever this is <ESC>

Code: Select all

( for /f %%a in ('echo prompt $E^| cmd') do set "esc=%%a" ) & <nul set /p "=!esc![?25l"
This is the line of code I use to capture it.

You can access it simply by using %esc% instead of <ESC>

Re: Batch coloring not working after git output

Posted: 19 May 2021 00:31
by jeb
Hallo Bleifuss,

I just tested it on Win10 and it worked,
but I'm sure I saw a similar post about broken escape sequences after some commands.
But as always I can't find the post anymore.

jeb