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.
🎦 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 - ⚡ 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
- Size Values: Light magenta (#FF80FF) - White on red background if size is 0
- Size Units: Orange (#FFB380)
- 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:
Operating Systems
- 🐧 Linux: x86_64, ARM64, ARMv7, i686 (+ musl variants)
- 🪟 Windows: x86_64, ARM64, i686
- 🍎 macOS: Intel (x86_64) and 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
# Show system folders (.git, etc.)
# Show version info
Command Line Options
Usage: tree2 [OPTIONS] [PATH]
Arguments:
[PATH] Target directory [default: .]
Options:
-a, --all Show hidden system folders (.git, .svn, etc.)
-e, --exception <PATTERNS>... Exception patterns (wildcards, regex, exact match)
-i, --ignore-file <FILES>... Specific ignore files to use
-c, --clipboard Copy result to clipboard
-x, --exclude <NAMES>... Exclude directories/files (exact match)
-V, --version Print version information
-h, --help Print help
New Features in v2.0
🌟 Multiple Ignore Files Support
Tree2 automatically loads ALL common ignore files:
.gitignore,.dockerignore,.npmignore.eslintignore,.prettierignore,.hgignore.terraformignore,.helmignore,.gcloudignore.cfignore,.slugignore.pt(custom ignore file for tree2)
Important: All patterns in ignore files support wildcards (* and ?). For example, *.exe in .gitignore will match all .exe files.
🛡️ Default System Folder Exclusion
Tree2 automatically hides these system folders and files by default:
.git,.svn,.hg,.bzr,_darcs,CVS.DS_Store,Thumbs.db,desktop.ini
To show these folders:
🎯 Exception Patterns (New!)
Exclude patterns from being ignored using the -e or --exception flag. Supports three types:
Wildcard Patterns:
# Keep all .log files even if ignored
# Keep specific pattern
# Multiple patterns
Exact Match:
# Keep specific file/folder
Regex Patterns:
Use regex: prefix for complex patterns:
# Keep all files ending with numbers
# Keep files matching pattern
📝 Selective Ignore File Usage
You can specify which ignore files to use:
# Use only .gitignore
# Use both .gitignore and .dockerignore
# Use custom ignore file
Advanced Examples
# Use only .gitignore but keep all .log files
# Use multiple ignore files with exceptions
# Exclude specific folders but keep exceptions
# Complex regex exception
# Show all including .git
# Combined flags
📄 Creating a .pt File
The .pt file works like .gitignore but is specific to tree2:
# Create .pt file
# tree2 will automatically use it
💡 Pattern Matching Examples
Wildcard Examples:
*.log- matches any file ending with .logtest_*- matches any file starting with test_*_backup.*- matches any file with _backup before extension?.txt- matches single character followed by .txt
Regex Examples:
regex:.*\d+$- matches files ending with numbersregex:^test.*\.rs$- matches Rust test filesregex:(debug|test)_.*- matches files starting with debug_ or test_
📋 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]
# .git folder is hidden by default ✓
Clipboard Output
When using -c flag, the output copied to clipboard is plain text without ANSI color codes, making it perfect for:
- Pasting into documentation
- Sharing in emails or chat
- Including in Markdown files
- Code reviews and discussions
🚀 Performance
The Rust version is optimized for performance:
- Zero-cost abstractions
- Minimal memory allocations
- Efficient directory traversal
- Fast pattern matching with HashSet
- Optimized wildcard matching algorithm
- Concurrent ignore file loading
📚 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 with arguments
Cross-Compilation
To build for a different platform:
# 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
v2.0.12 (Latest)
- 🐛 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! 🚀🦀
