Tree command line tool

Written on December 8, 2015

I just discovered a neat little command line tool called tree. What tree does is list the content of directories in a tree-like format. This is super useful if you want to quickly share a visual representation of a project’s file structure.

To install tree on Mac OS X, you could use hombrew and run brew install tree.

Once installed you can run tree and it’ll recursively print out the file structure for the current folder you are in.

tree has a lot of options that makes it super flexible on what you want it to print out. Such as tree -L 1 --dirsfirst. What this commands does is limits the depth of the tree to 1 level and prints directories before files.

What you’ll get is something like this:

.
├── _includes
├── _layouts
├── _posts
├── _sass
├── css
├── _config.yml
├── about.md
├── feed.xml
└── index.html

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image