Treex is a powerful command-line tool for displaying directory structures in different formats. It offers multiple output formats and flexible filtering options, making it easy to visualize and explore your project layout.
- ๐จ Multiple output formats:
- ๐ฒ
tree
: Tree format (default) - ๐
indent
: Indented list format - ๐
md
: Markdown format - ๐
mermaid
: Mermaid format
- ๐ฒ
- ๐ Flexible filtering options:
- ๐ต๏ธ
-H
: Hide hidden files and directories - ๐
-D
: Show directories only - ๐ซ
-e <rules>
: Exclude specific directories or file extensions - ๐
-I
: Automatically apply .gitignore rules
- ๐ต๏ธ
- ๐ ๏ธ Customizable output:
- ๐
-m <depth>
: Control directory depth - ๐พ
-o <path>
: Save output to a file - ๐ฏ
-f <format>
: Select output format - โญ
-C
: Show icons for files (via emoji)
- ๐
Download the pre-built binary from the releases page and add it to your PATH.
Or, if you want to build it yourself with Go:
go install github.com/shiquda/treex@latest
For windows user, you can use scoop to install treex:
scoop bucket add extras
scoop install treex
Basic usage:
treex -d <directory>
To generate a tree for the current directory, simply run:
treex
You can run treex -h
to see the help message.
All command-line options are listed in the table below:
Short Option | Long Option | Argument | Description | Default Value |
---|---|---|---|---|
-d |
--dir |
<directory> |
Directory to scan | . |
-f |
--format |
<format> |
Output format (tree , indent , md , mermaid ) |
tree |
-m |
--max-depth |
<number> |
Maximum directory depth (0 for unlimited) | - |
-o |
--output |
<filepath> |
Path to output file | stdout |
-e |
--exclude |
<rules> |
Exclude rules (comma-separated: dir/ for dirs, .ext for extensions) |
- |
-H |
--hide-hidden |
- | Hide hidden files and directories | false |
-D |
--dirs-only |
- | Show directories only | false |
-I |
--use-gitignore |
- | Exclude files/directories based on .gitignore |
false |
-C |
--icons |
- | Show file type icons | false |
Format options details:
tree
: Tree structure with branchesindent
: Indented list formatmd
: Markdown formatmermaid
: Mermaid format for diagrams
Exclude rules format:
dir/
: Exclude directories matching the specified name.ext
: Exclude files with the specified extension
The following examples use the same directory structure.
- Without hidden files, save output as markdown format:
treex -H -f md -o structure.md
-H
: Hide hidden files and directories-f md
: Output in Markdown format-o structure.md
: Save output to structure.md file
Result:
Then in ./structure.md
:
- ./
- 1.go
- 2.go
- README.md
- build/
- win/
- output.exe
- test/
- 3.go
- README_test.md
- Use .gitignore rules to exclude files:
.gitignore
:
build/
Run:
treex -IH
-I
: Exclude files/directories based on.gitignore
-H
: Hide hidden files and directories
This will automatically read the .gitignore
file in the current directory and exclude matching files and directories.
Result:
.
โโโ 1.go
โโโ 2.go
โโโ README.md
โโโ test
โโโ 3.go
โโโ README_test.md
- Generate mermaid diagram for visible directories only:
treex -HD -f mermaid
-H
: Hide hidden files and directories-D
: Show directories only-f mermaid
: Output in Mermaid diagram format
Result:
graph TD
N1[./]
N2[build/]
N1 --> N2
N3[win/]
N2 --> N3
N4[test/]
N1 --> N4
- Exclude specific directories or extensions:
treex -e ".git/, .md"
-e ".git/, .md"
: Exclude.git
directory and files with.md
extension
Result:
.
โโโ .gitignore
โโโ 1.go
โโโ 2.go
โโโ build
โ โโโ win
โ โโโ output.exe
โโโ test
โโโ 3.go
- Show files up to depth 2 in indent mo 905D de:
treex -m 2 -f indent
-m 2
: Show files up to depth 2-f indent
: Output in indented list format
Result:
./
.git/
HEAD
config
description
hooks/
info/
objects/
refs/
.gitignore
1.go
2.go
README.md
build/
win/
test/
3.go
README_test.md
- Display the file structure with icons (using a real project structure as an example):
treex -CHI -m 3
-C
: Show file type icons-H
: Hide hidden files and directories-I
: Exclude files/directories based on.gitignore
-m 3
: Show files up to depth 3
Result:
๐ ./
โโโ ๐ CODE_OF_CONDUCT.md
โโโ ๐ CONTRIBUTING.md
โโโ ๐ LICENSE
โโโ ๐ README.md
โโโ ๐ build/
โ โโโ ๐ entitlements.mac.plist
โ โโโ ๐ icon.icns
โ โโโ ๐ icon.ico
โ โโโ ๐ผ๏ธ icon.png
โ โโโ ๐ icons/
โ โ โโโ ๐ผ๏ธ 1024x1024.png
โ โ โโโ ๐ผ๏ธ 128x128.png
โ โ โโโ ๐ผ๏ธ 16x16.png
โ โ โโโ ๐ผ๏ธ 24x24.png
โ โ โโโ ๐ผ๏ธ 256x256.png
โ โ โโโ ๐ผ๏ธ 32x32.png
โ โ โโโ ๐ผ๏ธ 48x48.png
โ โ โโโ ๐ผ๏ธ 512x512.png
โ โ โโโ ๐ผ๏ธ 64x64.png
โ โโโ ๐ผ๏ธ logo.png
โ โโโ ๐ nsis-installer.nsh
โ โโโ ๐ผ๏ธ tray_icon.png
โ โโโ ๐ผ๏ธ tray_icon_dark.png
โ โโโ ๐ผ๏ธ tray_icon_light.png
โโโ โ๏ธ dev-app-update.yml
โโโ ๐ docs/
โ โโโ ๐ README.ja.md
โ โโโ ๐ README.zh.md
โ โโโ ๐ dev.md
โ โโโ ๐ sponsor.md
โ โโโ ๐ technical/
โ โโโ ๐ KnowledgeService.md
โโโ โ๏ธ electron-builder.yml
โโโ ๐ electron.vite.config.ts
โโโ ๐ eslint.config.mjs
โโโ ๐ package.json
โโโ ๐ packages/
โ โโโ ๐ artifacts/
โ โ โโโ ๐ README.md
โ โ โโโ ๐ package.json
โ โ โโโ ๐ statics/
โ โโโ ๐ database/
โ โ โโโ ๐ README.md
โ โ โโโ ๐ data/
โ โ โโโ ๐ package.json
โ โ โโโ ๐ src/
โ โ โโโ ๐ yarn.lock
โ โโโ ๐ shared/
โ โโโ ๐ IpcChannel.ts
โ โโโ ๐ config/
โโโ ๐ resources/
โ โโโ ๐ cherry-studio/
โ โ โโโ ๐ license.html
โ โ โโโ ๐ releases.html
โ โโโ ๐ data/
โ โ โโโ ๐ agents.json
โ โโโ ๐ js/
โ โ โโโ ๐ bridge.js
โ โ โโโ ๐ utils.js
โ โโโ ๐ scripts/
โ โ โโโ ๐ download.js
โ โ โโโ ๐ install-bun.js
โ โ โโโ ๐ install-uv.js
โ โโโ ๐ textMonitor.swift
โโโ ๐ scripts/
โ โโโ ๐ after-pack.js
โ โโโ ๐ build-npm.js
โ โโโ ๐ check-i18n.js
โ โโโ ๐ check-i18n.ts
โ โโโ ๐ cloudflare-worker.js
โ โโโ ๐ notarize.js
โ โโโ ๐ remove-locales.js
โ โโโ ๐ replace-spaces.js
โ โโโ ๐ update-i18n.ts
โ โโโ ๐ utils.js
โ โโโ ๐ version.js
โโโ ๐ src/
โ โโโ ๐ components/
โ โโโ ๐ main/
โ โ โโโ ๐ config.ts
โ โ โโโ ๐ constant.ts
โ โ โโโ ๐ electron.d.ts
โ โ โโโ ๐ embeddings/
โ โ โโโ ๐ env.d.ts
โ โ โโโ ๐ index.ts
โ โ โโโ ๐ integration/
โ โ โโโ ๐ ipc.ts
โ โ โโโ ๐ loader/
โ โ โโโ ๐ mcpServers/
โ โ โโโ ๐ reranker/
โ โ โโโ ๐ services/
โ โ โโโ ๐ utils/
โ โโโ ๐ preload/
โ โ โโโ ๐ index.d.ts
โ โ โโโ ๐ index.ts
โ โโโ ๐ renderer/
โ โโโ ๐ index.html
โ โโโ ๐ src/
โโโ ๐ tsconfig.json
โโโ ๐ tsconfig.node.json
โโโ ๐ tsconfig.web.json
โโโ ๐ yarn.lock
- Support config file, allow user to customize the default output format, filtering options, styles etc.
- Better performance for large directory trees
- Better way to show file/dir types
- Streamline installation process for MacOS & Linux systems(help needed!)
- And more! Tell me in issues if you have any ideas.
The project is in its early stages of development. All contributions are welcome, including raising issues, submitting pull requests, or giving the project a โญ star on GitHub!