useful tree command on mac

I found a simple way to produce tree-like listings of files/folders on the mac. This is a very useful tool to get an overview of some project code. You can install it simply (following instructions I found here).

First, open a terminal and install Homebrew if you do not have it already. It’s a package manager and will ask you for your password. If this doesn’t work, then perhaps the install code has changed, go to the Homebrew site.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install “tree” with…

brew install tree

then run it on the folder of interest. I did this on a local git repo for a paper I recently published.

tree /Users/benvincent/git-local/delay-discounting-analysis

After some manual removal of dependency code that I’m less interested, the output looks like this. Although it looks much better in a text editor (see screenshot).tree

/Users/benvincent/git-local/delay-discounting-analysis
├── LICENSE.txt
├── README.md
├── ddToolbox
│   ├── README.txt
│   ├── calculateLogK_ConditionOnReward.m
│   ├── classes
│   │   ├── DataClass.m
│   │   ├── JAGSSampler.m
│   │   ├── ModelBaseClass.m
│   │   ├── ModelHierarchical.m
│   │   ├── ModelHierarchicalNOMAG.m
│   │   ├── ModelLinear.m
│   │   ├── ModelSeperate.m
│   │   └── SamplerClass.m
│   ├── dependencies
│   │   ├── ColorBand
│   │   ├── export_fig
│   │   ├── fill_between
│   │   ├── hist2d
│   │   ├── kde
│   │   ├── kde2d
│   │   ├── latex_fig
│   │   ├── matjags
│   │   ├── repos
│   │   │   ├── PosteriorPredictionPlot.m
│   │   │   ├── fill_between.m
│   │   │   ├── kwargify.m
│   │   │   └── plotMCMCdist.m
│   │   └── savefig
│   │   ├── license.txt
│   │   └── savefig.m
│   ├── jagsModels
│   │   ├── hierarchicalME.txt
│   │   ├── hierarchicalNOMAG.txt
│   │   ├── linearModel.txt
│   │   └── seperateME.txt
│ etc etc

Leave a Reply