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.
- π¨ 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
- 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
Download the appropriate binary for your platform from GitHub Releases:
# x86_64 (Standard)
wget https://github.com/cumulus13/tree2/releases/latest/download/tree2-linux-amd64.tar.gz
tar xzf tree2-linux-amd64.tar.gz
sudo mv tree2 /usr/local/bin/
# ARM64 (Raspberry Pi 4+, AWS Graviton)
wget https://github.com/cumulus13/tree2/releases/latest/download/tree2-linux-arm64.tar.gz
tar xzf tree2-linux-arm64.tar.gz
sudo mv tree2 /usr/local/bin/
# ARMv7 (Raspberry Pi 2/3)
wget https://github.com/cumulus13/tree2/releases/latest/download/tree2-linux-armv7.tar.gz
tar xzf tree2-linux-armv7.tar.gz
sudo mv tree2 /usr/local/bin/Download from releases page and extract to a folder in your PATH.
# Intel Macs
wget https://github.com/cumulus13/tree2/releases/latest/download/tree2-macos-amd64.tar.gz
tar xzf tree2-macos-amd64.tar.gz
sudo mv tree2 /usr/local/bin/
# Apple Silicon (M1/M2/M3)
wget https://github.com/cumulus13/tree2/releases/latest/download/tree2-macos-arm64.tar.gz
tar xzf tree2-macos-arm64.tar.gz
sudo mv tree2 /usr/local/bin/cargo install tree2git clone https://github.com/cumulus13/tree2
cd tree2
cargo install --path .Tree2 supports 11 different platforms:
- π§ 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.
# Show current directory tree
tree2
# Show specific directory
tree2 /path/to/directory
# Copy output to clipboard
tree2 -c
# Show system folders (.git, etc.)
tree2 -a
# Show version info
tree2 -VUsage: 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
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.
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:
tree2 -a # Show all including system folders
tree2 --all # Same as aboveExclude patterns from being ignored using the -e or --exception flag. Supports three types:
Wildcard Patterns:
# Keep all .log files even if ignored
tree2 -e "*.log"
# Keep specific pattern
tree2 -e "important_*.txt"
# Multiple patterns
tree2 -e "*.log" "*.tmp" "debug_*"Exact Match:
# Keep specific file/folder
tree2 -e "node_modules"
tree2 -e ".env"Regex Patterns:
Use regex: prefix for complex patterns:
# Keep all files ending with numbers
tree2 -e "regex:.*\d+$"
# Keep files matching pattern
tree2 -e "regex:^(test|spec)_.*\.rs$"You can specify which ignore files to use:
# Use only .gitignore
tree2 -i .gitignore
# Use both .gitignore and .dockerignore
tree2 -i .gitignore .dockerignore
# Use custom ignore file
tree2 -i .myignore# Use only .gitignore but keep all .log files
tree2 -i .gitignore -e "*.log"
# Use multiple ignore files with exceptions
tree2 -i .gitignore .dockerignore -e "*.log" "*.md" "important_*"
# Exclude specific folders but keep exceptions
tree2 --exclude target build -e "target/debug/important_file.txt"
# Complex regex exception
tree2 -e "regex:^(test|spec).*\.(rs|py)$"
# Show all including .git
tree2 -a
# Combined flags
tree2 -a -i .gitignore -e "*.log"The .pt file works like .gitignore but is specific to tree2:
# Create .pt file
cat > .pt << EOF
# Custom ignores for tree2
*.tmp
*.cache
local_settings.json
dev_notes/
EOF
# tree2 will automatically use it
tree2*.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:.*\d+$- matches files ending with numbersregex:^test.*\.rs$- matches Rust test filesregex:(debug|test)_.*- matches files starting with debug_ or test_
π /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 β
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
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
Add to your Cargo.toml:
[dependencies]
tree2 = "2.0"use tree2::TreeBuilder;
fn main() {
let tree = TreeBuilder::new()
.path(".")
.excludes(vec!["target", ".git"])
.build();
tree.print();
}use tree2::{TreeBuilder, TreeConfig};
fn main() {
let config = TreeConfig {
path: ".".into(),
excludes: vec!["target".into(), ".git".into()],
ignore_files: vec![".gitignore".into(), ".dockerignore".into()],
exceptions: vec!["*.log".into()],
show_all: false,
max_depth: Some(5),
};
let tree = TreeBuilder::from_config(config).build();
tree.print();
// Or get the output as string
let output = tree.to_string();
println!("{}", output);
}[dependencies]
clap = { version = "4.0", features = ["derive"] }
dunce = "1.0.4"
cli-clipboard = "0.4"
clap-version-flag = "1.0.5"
regex = "1.10"- Rust 1.70 or higher
- Cargo
git clone https://github.com/cumulus13/tree2
cd tree2
# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with arguments
cargo run --release -- -e target -cTo build for a different platform:
# Install target
rustup target add aarch64-unknown-linux-gnu
# Build
cargo build --release --target aarch64-unknown-linux-gnu
# Or use cross for easier cross-compilation
cargo install cross
cross build --release --target aarch64-unknown-linux-gnuWe 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
This project is licensed under the MIT License - see the LICENSE file for details.
Hadi Cahyadi
- Email: [email protected]
- GitHub: cumulus13
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Read the Documentation
- Contact: [email protected]
- π 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
- β¨ 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)
- β
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
- 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! ππ¦