Batch coloring not working after git output

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Bleifuss
Posts: 1
Joined: 18 May 2021 01:06

Batch coloring not working after git output

#1 Post by Bleifuss » 18 May 2021 01:33

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.

IcarusLives
Posts: 161
Joined: 17 Jan 2016 23:55

Re: Batch coloring not working after git output

#2 Post by IcarusLives » 18 May 2021 17:06

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>

jeb
Expert
Posts: 1041
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Batch coloring not working after git output

#3 Post by jeb » 19 May 2021 00:31

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

Post Reply