如何缩进 git-clone 的输出

How to indent output of git-clone

我一直在尝试缩进 git 克隆的输出。我尝试使用 sed 但它不起作用...这是我到目前为止所尝试的方法。

git clone https://github.com/test/HelloWorld --progress | sed 's/^/  /g'

有没有人有什么想法?

Git 输出到标准输出和标准错误。要过滤两者,您可以使用 |&2&1 |.

它还会打印使用 [​​=13=] 回车 returns 更新的进度线。除了正常行之外,您还可以使用正则表达式缩进这些行。我还将使用 -u 进行无缓冲输入和输出。

git clone https://github.com/test/HelloWorld --progress |&
    sed -ur 's/(^|\r)/  /g'

请注意,sed 是基于行的,仅在遇到 \n 换行时才打印输出。用 \r 回车分隔的行 returns 可以在打印前缓冲一段时间。

一旦我发现 pr:

git clone https://github.com/test/HelloWorld --progress 2>&1 | pr -tro 3