開発しているとコード解析や仕様書作成などファイル構成を知りたい場合がある。普段Windowsを使うことも多いので、Winではコマンドプロンプトのtreeコマンドでディレクトリやファイル構成をtree状で表示していた。Macのターミナルで同じことをしようとすると、treeコマンドがデフォでは使えないことがわかったのでインストールすることにする。
[環境]
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
CPU: quad-core 64-bit
OS X: 10.9.4-x86_64
hogehoge:$ tree -bash: tree: command not found hogehoge:$
Homebrew によるtreeコマンドのインストール
$ brew install tree
hogehoge:$ sudo brew install tree ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/tree-1.7.0.mavericks.bottle.tar.gz ########################################### 100.0% ==> Pouring tree-1.7.0.mavericks.bottle.tar.gz /usr/local/Cellar/tree/1.7.0: 7 files, 128K hogehoge:$
brew install tree コマンドでインストールする。
動作確認
$ tree
hogehoge:$ tree 略 ├── functions.php ├── genericons │ ├── COPYING.txt │ ├── Genericons-Regular.otf │ ├── LICENSE.txt │ ├── README.txt │ ├── example.html │ ├── font │ │ ├── genericons-regular-webfont.eot │ │ ├── genericons-regular-webfont.svg │ │ ├── genericons-regular-webfont.ttf │ │ └── genericons-regular-webfont.woff │ └── genericons.css ├── header.php
ファイル構成を知りたいディレクトリをカレントにして、treeコマンドを叩けば tree表示することが確認できた。