I found this cool progress bar I'm using: https://stackoverflow.com/a/27147177/1480397
But I have no clue what it is doing and I'm failing to google it.
"\r\033[0G\033[2K[%'={$percentageDone}s>%-{$percetageLeft}s] - $percentageDone%% - $absoluteDone/$absoluteTotal - avg %.4f - %s",
This is what I'm using.
I think the sequences are:
\r
- carriage return, go back to start\033[0G
-Esc[0g
Clear a tab at the current column` *\033[2K
-Esc[2K
Clear entire line *[%'={$percentageDone}s>%-{$percetageLeft}s]
*
This doesn't do what I expect, when I remove the code, Source: http://ascii-table.com/ansi-escape-sequences-vt-100.php
So, are these sequences extracted correctly? Is the interpretation correct? And why is the last writing cool bars?
[====> <much more spaces> ]
Code to test:
for ($i = 0; $i <= 100; $i++) {
$absoluteDone = $i;
$absoluteTotal = 100;
$percentageDone = floor(($absoluteDone / $absoluteTotal) * 100);
$percetageLeft = 100 - $percentageDone;
$avgTime = 10;
$setCursorToLineStart = "\033[0G";
$clearLine = "\033[2K";
$progressbarAndStatusInfo = sprintf(
$setCursorToLineStart
. $clearLine
. "[%'={$percentageDone}s>%-{$percetageLeft}s] - $percentageDone%% - $absoluteDone/$absoluteTotal - avg %.4f - %s",
"",
"",
$avgTime,
gmdate("H:i:s", $avgTime * ($absoluteTotal - $absoluteDone))
);
echo $progressbarAndStatusInfo;
sleep(1);
}