将文本行换行到指定的字符长度限制,支持 ansi 颜色代码

Wrap lines of text to a specified character length limit with support for ansi color codes

我想换行一些文本以适合我的终端。我目前使用 fold -s -w 80 但这会计算 ansi 颜色代码,这使得它过早地包裹了彩色线条。

# brew install cpanm
cpanm App::ansifold
# cpanm -V # to find install dir
# /usr/local/Cellar/perl/5.30.1/bin/ansifold
# use just like fold: `ansifold -s -w 80`

ansifold 正确换行文本的示例屏幕截图: