LoginSignup
12
9

More than 5 years have passed since last update.

treeコマンドの表示条件を指定する

Posted at

Linuxコマンドにはtreeというものがあり、実行したディレクトリ配下のファイルをツリー状に表示してくれます。

$ tree
.
├── .gitignore
├── README.md
├── package.json
├── public
│   └── index.html
├── src
│   ├── actions
│   ├── components
│   ├── containers
│   │   └── App.tsx
│   └── index.tsx
├── tsconfig.json
├── tslint.json
├── webpack.config.js
└── yarn.lock

*Macの場合デフォルトでは使えないですが、homebrew等を使って入れることができます

$ brew install tree

このtreeコマンドですが、デフォルトでは.から始まるファイルを表示できなかったり、node_modulesのようなディレクトリも展開して表示してしまいます。

そこで、僕はこんな感じでaliasを指定してます

.zshrc|.bash_profile
alias tree = 'tree -a -I "\.DS_Store|\.git|node_modules|vendor\/bundle" -N'

-a

.から始まるファイルも含める

-I

|つなぎでパターンを指定して結果から除外する

-N

表示できない文字(日本語)も表示する

他にも色々オプションがあります。

12
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
9