tree command on osx bash tree command on osx bash unix unix

tree command on osx bash


Using homebrew:

brew install tree

Using macports:

sudo port install tree

Using the source:

Follow these directions. (Caveat; you should use the flags/etc. that make sense.)

<rant>All systems should come with tree; I use it a lot. And we can post directory structures as text, not pics.</rant>


For a simple approach you can also add the following alias to your ~/.bashrc or ~/.zshrc file:

alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"

This results in the following:

$ tree.|____.git| |____config| |____objects| | |____pack| | |____info| |____HEAD| |____info| | |____exclude| |____description| |____hooks| | |____commit-msg.sample| | |____pre-rebase.sample| | |____pre-commit.sample| | |____applypatch-msg.sample| | |____pre-receive.sample| | |____prepare-commit-msg.sample| | |____post-update.sample| | |____pre-applypatch.sample| | |____pre-push.sample| | |____update.sample| |____refs| | |____heads| | |____tags

Found this solution here:


Not exactly the same, but gives you a list of all directories and files in those directories using:

find .

You can also specify list directories only

find -type d

or if you want to see files only

find -type f

you can also specify depth

find -type d -maxdepth 2