I use the following command to print a directory structure to a file:
tree -h somepath/ > tree_of_somepath.txt
tree
gives a nice colorized output on the terminal, but as expected this cannot be redirected to a text file. I would like to print the output of tree
to a pdf file and preserve the color.
Any ideas?
Install the following dependencies:
Save your
tree
command output to html withaha
:From the
tree
man page,-C
forces colorization:Finally export the html to pdf with
wkhtmltopdf
:Example: