Tree2
A high-performance directory tree visualization tool written in Rust with colors, emojis, and comprehensive ignore file support. Available as both CLI tool and library crate. Fully compatible with Linux tree command options.
🎦 Demo
✨ Features
- 🎨 Colorful Output: Beautiful colored output with emojis for better visualization
- 📊 File Sizes: Human-readable file sizes with color-coded values
- 🚫 Multiple Ignore Files: Automatic support for
.gitignore,.dockerignore,.pt, and more - 🔒 Default System Exclusions:
.git,.svn, and other system folders hidden by default - 🎯 Exception Patterns: Wildcard and regex support to override ignore rules
- 📋 Clipboard Support: Copy tree output directly to clipboard with
-cflag - 🐧 Linux
treeCompatible: Supports all major flags from the Linuxtreecommand - ⚡ Blazing Fast: Optimized Rust implementation for maximum performance
- 🌐 Cross-Platform: Works on Windows, macOS, Linux (x86_64, ARM64, ARMv7, i686)
- 📦 Library & CLI: Available as both command-line tool and Rust library
- 🦀 Memory Safe: Rust's safety guarantees ensure reliability
🎨 Color Scheme
- Folders: Bright Yellow (#FFFF00) with 📁 emoji
- Files: Bright Cyan (#00FFFF) with 📄 emoji
- Symlinks: Bright Green (#00FF80) with
->target path - Size Values: Light magenta (#FF80FF) — White on red background if size is 0
- Size Units: Orange (#FFB380)
- Meta info (permissions, date, owner): Gray (#A0A0A0)
- Permission Denied: White on red background with 🔒 emoji
🛠️ Installation
Using Pre-built Binaries (Recommended)
Download the appropriate binary for your platform from GitHub Releases:
Linux
# x86_64 (Standard)
# ARM64 (Raspberry Pi 4+, AWS Graviton)
# ARMv7 (Raspberry Pi 2/3)
Windows
Download from releases page and extract to a folder in your PATH.
macOS
# Intel Macs
# Apple Silicon (M1/M2/M3)
From crates.io
From Source
🌐 Platform Support
Tree2 supports 11 different platforms:
| OS | Architectures |
|---|---|
| 🐧 Linux | x86_64, ARM64, ARMv7, i686 (+ musl variants) |
| 🪟 Windows | x86_64, ARM64, i686 |
| 🍎 macOS | Intel (x86_64), Apple Silicon (ARM64) |
For detailed platform information, see PLATFORM_SUPPORT.md.
📖 Usage
Basic Usage
# Show current directory tree
# Show specific directory
# Copy output to clipboard (plain text, no ANSI codes)
# Show system folders (.git, etc.)
# Show version info
# Show help
Note:
-his--human-readable(Linuxtreecompatibility), not--help. Use--helpfor the help screen.
📋 Full Options Reference
Usage: tree2 [OPTIONS] [PATH]
Arguments:
[PATH] Target directory [default: .]
Original tree2 flags
| Flag | Description |
|---|---|
-V, --version |
Print version information |
-e, --exclude <NAME>... |
Exclude directories/files by exact name |
-c, --clipboard |
Copy output to clipboard (plain text) |
-i, --ignore-file <FILE>... |
Specific ignore file(s) to use |
--exception <PATTERN>... |
Exception patterns — matching entries will NOT be excluded (supports wildcards and regex: prefix) |
-a, --all |
Show hidden system folders (.git, .svn, etc.) |
Listing & filtering (Linux tree compatible)
| Flag | Description |
|---|---|
-d, --dirs-only |
List directories only |
-f, --full-path |
Print full path prefix for each entry |
-l, --follow-links |
Follow symbolic links like directories |
-L, --level <N> |
Max display depth |
-P, --pattern <GLOB> |
Only show files matching wildcard pattern (e.g. "*.rs") |
-I, --ignore-pattern <GLOB> |
Exclude files matching wildcard pattern (e.g. "*.o") |
--ignore-case |
Case-insensitive -P / -I matching |
--dirsfirst |
List directories before files |
-t, --sort-time |
Sort by last modification time (oldest first) |
-r, --reverse |
Reverse sort order |
--filelimit <N> |
Don't descend directories with more than N entries |
--prune |
Omit empty directories from output |
-x, --xdev |
Stay on current filesystem (don't cross mount points) — Unix only |
File metadata display (Linux tree compatible)
| Flag | Description |
|---|---|
-p, --protections |
Print permissions like [drwxr-xr-x] |
-u, --owner |
Print file owner name / UID — Unix only |
-g, --group |
Print group name / GID — Unix only |
-s, --size |
Print size in raw bytes |
-h, --human-readable |
Human-readable size (already the default; explicit flag for compat) |
--si |
Human-readable with SI units (powers of 1000) |
-D, --date |
Print last modification date/time |
-F, --classify |
Append type indicators: / dirs, * executables, @ symlinks, | FIFOs, = sockets |
--du |
Report directory size as accumulation of all contained file sizes |
--inodes |
Print inode number — Unix only |
--device |
Print device number — Unix only |
Output control (Linux tree compatible)
| Flag | Description |
|---|---|
--noreport |
Suppress the final N directories, M files summary |
-o, --output <FILE> |
Write output to file (plain text, no ANSI codes) |
-n, --nocolor |
Disable all ANSI colors |
-q, --quote-chars |
Replace non-printable characters with ? |
-Q, --quote |
Wrap filenames in double quotes |
💡 Usage Examples
Depth & filtering
# Show only 2 levels deep
# Show only Rust source files
# Show only directories, 3 levels deep
# Exclude all .o files
# Case-insensitive pattern match
Sorting
# Directories first
# Sort by modification time, newest last
# Reverse order
# Newest first (reverse time sort)
Metadata display
# Show permissions
# Show permissions + owner + group
# Show modification date
# Show size in bytes
# Show size with SI units (1000-based)
# Show accumulated directory sizes
# Show inode numbers (Unix only)
# Show all metadata at once
Output
# Save to file (no ANSI codes)
# Copy to clipboard
# No colors
# Suppress file/dir count summary
# Quote all filenames
Combining flags
# Use only .gitignore, keep all .log files
# Show all files matching pattern, dirs first, with dates
# Complex metadata view with depth limit
# Stay on current filesystem only (Unix)
# Full path + classify indicators
Exception patterns
# Wildcard: keep all .log files even if in .gitignore
# Exact match: keep node_modules
# Regex pattern: keep test/spec Rust files
# Multiple exceptions
📄 Creating a .pt File
The .pt file works like .gitignore but is specific to tree2:
# tree2 will automatically use it
📋 Output Example
📂 /home/user/project/
├── 📁 src/
│ ├── 📄 main.rs (12.45 KB)
│ └── 📄 lib.rs (2.34 KB)
├── 📁 tests/
│ └── 📄 integration_test.rs (2.10 KB)
├── 📄 Cargo.toml (1.20 KB)
├── 📄 README.md (4.50 KB)
└── 🔒 [Permission Denied]
2 directories, 4 files
With metadata flags (-p -u -D)
📂 /home/user/project/
├── [-rwxr-xr-x] alice [2025-11-22 14:30] 📁 src/
│ └── [-rw-r--r--] alice [2025-11-20 09:15] 📄 main.rs (12.45 KB)
└── [-rw-r--r--] alice [2025-11-21 11:00] 📄 Cargo.toml (1.20 KB)
1 directory, 2 files
Clipboard Output
When using -c, the output copied to clipboard is plain text without ANSI color codes, making it perfect for pasting into documentation, emails, Markdown files, or code reviews.
🚀 Performance
- Zero-cost abstractions
- Minimal memory allocations
- Efficient directory traversal
- Fast pattern matching with HashSet
- Optimized wildcard matching algorithm
📚 Library Usage
Add to your Cargo.toml:
[]
= "2.0"
Basic Example
use TreeBuilder;
Advanced Example
use ;
🔧 Dependencies
[]
= { = "4.0", = ["derive"] }
= "1.0.4"
= "0.4"
= "1.0.5"
= "1.10"
🏗️ Building from Source
Prerequisites
- Rust 1.70 or higher
- Cargo
Build Steps
# Debug build
# Release build
# Run tests
# Run clippy
# Check formatting
Cross-Compilation
# Install target
# Build
# Or use cross for easier cross-compilation
🤝 Contributing
We welcome contributions!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Hadi Cahyadi
- Email: cumulus13@gmail.com
- GitHub: cumulus13
💬 Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Read the Documentation
- Contact: cumulus13@gmail.com
📝 Changelog
v1.0.14 (Latest)
- ✨ Added: Full Linux
treecommand compatibility - ✨ Added:
-L/--levelmax depth flag - ✨ Added:
-d/--dirs-onlydirectories-only listing - ✨ Added:
-f/--full-pathfull path prefix display - ✨ Added:
-P/--patternand-I/--ignore-patternwildcard filtering - ✨ Added:
--ignore-casefor case-insensitive pattern matching - ✨ Added:
--dirsfirstsort order - ✨ Added:
-t/--sort-timeand-r/--reversesort flags - ✨ Added:
-p/--protectionspermissions display (Unix) - ✨ Added:
-u/--ownerand-g/--groupmetadata (Unix) - ✨ Added:
-s/--sizeraw bytes,-h/--human-readable,--sisize flags - ✨ Added:
-D/--datemodification date display - ✨ Added:
-F/--classifytype indicator suffixes - ✨ Added:
--filelimitdirectory entry limit - ✨ Added:
--pruneempty directory pruning - ✨ Added:
--duaccumulated directory sizes - ✨ Added:
--noreportsuppress summary line - ✨ Added:
-o/--outputwrite to file - ✨ Added:
-n/--nocolordisable ANSI colors - ✨ Added:
-q/--quote-charsand-Q/--quotefilename quoting - ✨ Added:
-x/--xdevstay on current filesystem (Unix) - ✨ Added:
--inodesand--deviceinode/device display (Unix) - ✨ Added: Summary line
N directories, M filesat end of output - ✨ Added: Symlink display with
->target in bright green - ✨ Added: Meta-info prefix colored in gray
- 🐛 Fixed: Cross-platform build — all Unix-specific APIs gated with
#[cfg(unix)] - 🐛 Fixed: All clippy warnings (
is_multiple_of,sort_by_key, argument count) - ⚠️ Breaking:
-his now--human-readable(Linux tree compat). Use--helpfor help.
v1.0.13
- 🐛 Fixed: Wildcard pattern matching in ignore files (
.gitignore,.pt, etc.) - 🐛 Fixed: Tree connector logic for correct display
- ✨ Added: Default system folder exclusion (
.git,.svn, etc.) - ✨ Added:
-a/--allflag to show hidden system folders - 📚 Improved: Documentation and troubleshooting guides
v1.0.10
- ✨ Added: Multiple ignore file support (
.gitignore,.dockerignore,.pt, etc.) - ✨ Added: Exception patterns with wildcard, regex, and exact match
- ✨ Added: Selective ignore file usage with
-iflag - ✨ Added: Custom
.ptignore file support - 🚀 Improved: Pattern matching algorithm
- 📚 Added: Comprehensive documentation (QUICKSTART, EXAMPLES, TROUBLESHOOTING)
v1.0.9
- ✅ Fixed exact match exclusion (
.gitno longer excludes.github) - ✨ Added clipboard support with
-cflag - 📝 Improved version info with
-Vflag - 🎨 Better color scheme with true color support
- ⚡ Performance optimizations
🔗 Links
- QUICKSTART Guide - Get started in 5 minutes
- Examples - 48+ practical usage examples
- Platform Support - Detailed platform information
- Changelog - Full version history
Enjoy blazing-fast directory visualization with Tree2! 🚀🦀
