-
Instale as seguintes dependências:
sudo apt-get install aha wkhtmltopdf
-
Salve a saída do comando
tree
em html comaha
:tree -C -h | aha > foo.html
Na página do manual
tree
,-C
força a colorização:-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.
-
Por fim, exporte o html para o pdf com
wkhtmltopdf
:wkhtmltopdf foo.html foo.pdf
Exemplo:
cd /tmp
tree -C -h | aha > foo.html
wkhtmltopdf foo.html foo.pdf
xdg-open foo.pdf