I've been trying to indent the output of git clone. I tried using sed but it isn't working... here's what I've tried so far.
git clone https://github.com/test/HelloWorld --progress | sed 's/^/ /g'
Does anyone have any ideas?
CodePudding user response:
Git outputs to both stdout and stderr. To filter both you can use |& or 2&1 |.
It also prints progress lines that are updated in place with \r carriage returns. You could use a regex to also indent those lines in addition to the normal ones. I would also use -u for unbuffered input and output.
git clone https://github.com/test/HelloWorld --progress |&
sed -ur 's/(^|\r)/\1 /g'
Note that sed is line-based and only prints output when it hits a \n newline. Lines separated with \r carriage returns could be buffered up for a while before being printed.
CodePudding user response:
Once I found pr:
git clone https://github.com/test/HelloWorld --progress 2>&1 | pr -tro 3
