Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format the output of tree in linux so the colour scheme still applies?

Tags:

linux

tree

How can I format the output of a tree command so that the formatting of ls, e.g. highlighting and colour scheme of directories and certain file types applies to the output? The problem is when I restrict the depth of tree to say 2, if there are any directories in the final level, there is not a noticeable difference between dirs and files. So someway to easily distinguish between the two, whilst displaying both files and dirs would be great. Any help would be appreciated.

like image 996
A Coder Avatar asked Jan 25 '17 11:01

A Coder


2 Answers

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.

see man page.

like image 123
naXa Avatar answered Sep 30 '22 20:09

naXa


I usually use tree with Level 2, so this my favorite alias:

tre='tree -CL 2'

enter image description here

like image 36
DimiDak Avatar answered Sep 30 '22 20:09

DimiDak