https://github.com/shiquda/treex
đŗâ: Treex is a CLI for directory structure visualization in various formats with powerful filters.
https://github.com/shiquda/treex
cli command-line-tool golang
Last synced: 11 months ago
JSON representation
đŗâ: Treex is a CLI for directory structure visualization in various formats with powerful filters.
- Host: GitHub
- URL: https://github.com/shiquda/treex
- Owner: shiquda
- License: mit
- Created: 2025-04-10T13:43:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-16T09:22:26.000Z (about 1 year ago)
- Last Synced: 2025-06-10T05:05:33.870Z (about 1 year ago)
- Topics: cli, command-line-tool, golang
- Language: Go
- Homepage:
- Size: 99.6 KB
- Stars: 134
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# đŗâ Treex
[](https://golang.org)
[](LICENSE)
[](https://github.com/shiquda/treex/releases)
[](https://goreportcard.com/report/github.com/shiquda/treex)

[įŽäŊ䏿](/docs/README_zh-cn.md)
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.
## ⨠Features
- đ¨ 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 `: Exclude specific directories or file extensions
- đ `-I`: Automatically apply .gitignore rules
- đ ī¸ Customizable output:
- đ `-m `: Control directory depth
- đž `-o `: Save output to a file
- đ¯ `-f `: Select output format
- â `-C`: Show icons for files (via emoji)
## đĻ Installation
Download the pre-built binary from the [releases](https://github.com/shiquda/treex/releases) page and add it to your PATH.
Or, if you want to build it yourself with Go:
```bash
go install github.com/shiquda/treex@latest
```
For windows user, you can use [scoop](https://scoop.sh/scoop) to install treex:
```bash
scoop bucket add extras
scoop install treex
```
## đ Usage
Basic usage:
```bash
treex -d
```
To generate a tree for the current directory, simply run:
```bash
treex
```
### âī¸ Full Options
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 to scan | `.` |
| `-f` | `--format` | `` | Output format (`tree`, `indent`, `md`, `mermaid`) | `tree` |
| `-m` | `--max-depth` | `` | Maximum directory depth (0 for unlimited) | - |
| `-o` | `--output` | `` | Path to output file | stdout |
| `-e` | `--exclude` | `` | 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 branches
- `indent`: Indented list format
- `md`: Markdown format
- `mermaid`: Mermaid format for diagrams
Exclude rules format:
- `dir/`: Exclude directories matching the specified name
- `.ext`: Exclude files with the specified extension
## đ Examples
The following examples use the same directory structure.
1. Without hidden files, save output as markdown format:
```bash
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`:
```markdown
- ./
- 1.go
- 2.go
- README.md
- build/
- win/
- output.exe
- test/
- 3.go
- README_test.md
```
2. Use .gitignore rules to exclude files:
`.gitignore`:
```text
build/
```
Run:
```bash
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:
```text
.
âââ 1.go
âââ 2.go
âââ README.md
âââ test
âââ 3.go
âââ README_test.md
```
3. Generate mermaid diagram for visible directories only:
```bash
treex -HD -f mermaid
```
- `-H`: Hide hidden files and directories
- `-D`: Show directories only
- `-f mermaid`: Output in Mermaid diagram format
Result:
```mermaid
graph TD
N1[./]
N2[build/]
N1 --> N2
N3[win/]
N2 --> N3
N4[test/]
N1 --> N4
```
4. Exclude specific directories or extensions:
```bash
treex -e ".git/, .md"
```
- `-e ".git/, .md"`: Exclude `.git` directory and files with `.md` extension
Result:
```text
.
âââ .gitignore
âââ 1.go
âââ 2.go
âââ build
â âââ win
â âââ output.exe
âââ test
âââ 3.go
```
5. Show files up to depth 2 in indent mode:
```bash
treex -m 2 -f indent
```
- `-m 2`: Show files up to depth 2
- `-f indent`: Output in indented list format
Result:
```text
./
.git/
HEAD
config
description
hooks/
info/
objects/
refs/
.gitignore
1.go
2.go
README.md
build/
win/
test/
3.go
README_test.md
```
6. Display the file structure with icons (using a real project structure as an example):
```bash
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:
```text
đ ./
âââ đ 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
```
## đ To Do
- [ ] 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.
## âĨī¸ Contribution
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!
## â Star History