struct
A Rust-based tree alternative that actually respects your sanity.
The Problem
Running tree in a project directory gives you this:
I needed something that shows project structure without drowning me in dependency folders.
What This Does
struct shows your project's actual structure while automatically hiding the noise:
)
The folder still appears, but you get a clean file count instead of thousands of irrelevant paths.
Installation
Option 1: Install from crates.io
The easiest way is to install directly via Cargo (make sure you have Rust installed):
View on crates.io
Option 2: Install from source
git clone https://github.com/caffienerd/struct-cli.git
cd struct-cli
chmod +x install.sh && ./install.sh
Uninstallation
&&
&&
Quick Start
Complete Usage Guide
struct 0 - Directory Summary Mode
When you run struct 0, you get a detailed summary of the current directory with stats for each item:
Output:
/home/user/projects/myproject (main)
src/
/home/user/projects/myproject/src
total: 10 dirs · 45 files · 125.3K
visible: 8 dirs · 42 files · 120.1K
types: rs(30) toml(5) md(3) json(2) txt(2)
ignored: target(948 files)
README.md
/home/user/projects/myproject/README.md
12.5K
.gitignore
/home/user/projects/myproject/.gitignore
486B
── ignored (top level) ──
.git(60 files), target(948 files) · 1008 files · 45.2M
What it shows:
- Current directory path with git branch
- For each directory:
- Full path
- Total stats (all files recursively)
- Visible stats (excluding ignored folders)
- File type breakdown
- Ignored subdirectories
- For each file:
- Full path
- File size
- Summary of top-level ignored items
Use cases:
- Quick directory analysis
- Find what's taking up space
- See project composition at a glance
- Identify ignored bloat
Basic Tree Display
Show directory structure with depth limit:
DEPTH: How many levels to show (default: infinite, 0 = current dir only)- Use
-por--pathto specify a different directory
Examples:
Git Integration
struct now has comprehensive git support, allowing you to filter files by their git status.
-g, --git
Show only git-tracked files (ignores everything not in git).
Output:
src/
├── main.rs (tracked)
├── lib.rs (tracked)
└── utils.rs (tracked)
tests/
└── integration_test.rs (tracked)
Use case: Clean view of actual source code without build artifacts.
--gu
Show only untracked files (not yet added to git).
Output (color-coded red for visibility):
.env (untracked)
debug.log (untracked)
tmp/
└── cache.tmp (untracked)
--gs
Show only staged files (ready to commit).
Output (color-coded green for visibility):
src/
├── main.rs (staged)
└── lib.rs (staged)
README.md (staged)
--gc
Show only modified/changed files (unstaged changes).
Output (color-coded yellow for visibility):
src/
├── main.rs (modified)
└── config.rs (modified)
tests/unit_test.rs (modified)
--gr
Start from git root (repository root) with any git mode. Useful when inside a subdirectory of a git repo.
Use case: Get consistent output regardless of your current working directory within the repository.
Git Mode Features:
- Color-coded output: Green (staged), Yellow (modified), Red (untracked)
- Git branch display: Shows current branch in output
- Clean filtering: Automatically respects
.gitignore - Combinable: Can combine git modes with other flags like
-zfor sizes
Examples:
Flags and Options
-z, --size
Show file sizes for all files and ignored directories.
Output:
main.rs (8.5K)
venv/ (156.3M, 2741 files ignored)
-p, --path PATH
Specify directory to display (default: current directory).
-g, --git
Deprecated: Use Git Integration section above instead. This flag shows git-tracked files.
-s, --skip-large SIZE_MB
Skip folders larger than specified size in megabytes.
Output:
node_modules/ (450MB, skipped)
-i, --ignore PATTERNS
Add custom ignore patterns (comma-separated, wildcards supported).
-n, --no-ignore MODE
Disable ignores selectively. MODE can be:
all- Disable ALL ignores (show everything)defaults- Disable built-in defaults (venv, node_modules, etc.)config- Disable config file patterns onlyPATTERN- Show specific folder (e.g.,venv,node_modules)
--version
Display the version of struct-cli.
Output:
struct-cli 0.4.2
Combining flags:
Config File Management
Save ignore patterns permanently instead of typing -i every time.
Location: ~/.config/struct/ignores.txt
struct add PATTERN
Add a pattern to permanent ignores.
struct remove PATTERN
Remove a pattern from config.
struct list
Show all saved patterns.
Output:
custom ignore patterns:
chrome_profile
*.log
temp*
config file: /home/user/.config/struct/ignores.txt
struct clear
Delete all custom patterns.
Search
Find files AND directories by pattern across your project.
Basic search:
Search options:
-d, --depth DEPTH
Limit search depth (default: 0 = infinite).
-f, --flat
Show flat list of full paths instead of tree.
Tree output (default):
found 12 file(s) matching *.py
01_python/
├── calculator/
│ └── KalQl8er.py (24.4K)
├── bgm/
│ └── BGM.py (44.5K)
└── timebomb/
└── timebomb.py (5.7K)
Flat output (-f):
found 12 file(s) matching *.py
/home/user/projects/01_python/calculator/KalQl8er.py (24.4K)
/home/user/projects/01_python/bgm/BGM.py (44.5K)
/home/user/projects/01_python/timebomb/timebomb.py (5.7K)
Note: Search results include both files and directories matching your pattern.
Combining search options:
Auto-Ignored Directories
These are hidden by default (folder shown with file count):
Python:
__pycache__,.pytest_cache,.mypy_cache,.ruff_cache*.pyc,*.pyo,*.pydfiles*.egg-info,dist,build,.toxvenv,.venv,env,virtualenv
JavaScript/Node:
node_modules,.npm,.yarn
Version Control:
.git,.svn,.hg
IDEs/Editors:
.vscode,.idea,.obsidian*.swp,*.swofiles
Build Artifacts:
target(Rust/Java)bin,obj(C#).next,.nuxt(JS frameworks)
Caches:
chrome_profile,lofi_chrome_profileGPUCache,ShaderCache,GrShaderCacheCache,blob_storage
Other:
.DS_Store(macOS)
Use -n all to show everything, or -n PATTERN to show specific folders.
Features
- Color-coded output: Directories in blue, executables in green
- File counts: Shows how many files are being hidden
- Git integration: Filter to only git-tracked files
- Size awareness: Skip folders over a certain size
- Configurable: Save your ignore patterns permanently
- Fast search: Find files with pattern matching
- Flexible output: Tree or flat format
Real-World Examples
Check project structure without clutter:
Find all config files:
See what's actually tracked in git:
Peek inside an ignored folder:
Find large folders:
Search with flat output for grep/scripting:
|
Why Rust
This started as a learning project to get hands-on with Rust. Turned out to be genuinely useful, so I polished it up. The performance is a nice bonus.
Contributing
Found a bug? Want a feature? Open an issue. PRs welcome.
License
MIT - feel free to do whatever you want with it!