Answers:
安装以下依赖项:
sudo apt-get install aha wkhtmltopdf
使用以下tree命令将命令输出保存到html中aha:
tree -C -h | aha > foo.html
从tree手册页-C强制着色:
-C Turn colorization on always, using built-in color defaults
if the LS_COLORS environment variable is not set. Useful to
colorize output to a pipe.
最后使用以下命令将html导出为pdf wkhtmltopdf:
wkhtmltopdf foo.html foo.pdf
例:
cd /tmp
tree -C -h | aha > foo.html
wkhtmltopdf foo.html foo.pdf
xdg-open foo.pdf

tree -n -d --charset unicode > file。它绝对不是那么漂亮,但是当我放牧数据文件时,我将它与单色激光打印机一起使用。–