つまりなにしたの?
Blogを書いていると、こういうディレクトリ構造にしていますよ。って話をしたくなる。
同じ課題を持つ人はいるらしく、そういうのをいい感じにテキストで出力するtreeコマンドを紹介する。
インストールする
brew install tree
使ってみる
% tree . ├── bar └── foo ├── fuga.txt └── hoge 3 directories, 1 file
もしくはファイルパスを指定して
% tree /Users/your_user/dev /Users/your_user/dev ├── bar └── foo ├── fuga.txt └── hoge 3 directories, 1 file
こんな感じで出てくる
よく使うオプションとか
- 階層の深さを指定する
% tree -L 1 . ├── bar └── foo 2 directories, 0 files
- ファイルとかディレクトリのサイズをも合わせて表示する
% tree -s . ├── [ 64] bar └── [ 128] foo ├── [ 12] fuga.txt └── [ 64] hoge 3 directories, 1 file
- パーミッション、ユーザ、グループも合わせて表示する
% tree -pug . ├── [drwxr-xr-x who group ] bar └── [drwxr-xr-x who group ] foo ├── [-rw-r--r-- who group ] fuga.txt └── [drwxr-xr-x who group ] hoge 3 directories, 1 file
- 今のパスからの相対パスを全部表示する
% tree -f . ├── ./bar └── ./foo ├── ./foo/fuga.txt └── ./foo/hoge 3 directories, 1 file