tree - Cross-Platform tree cli written in Rust
tree is an open-source tree command-line application that recursively displays the directory structure of a given path in a tree-like format, inspired by the Unix tree command. It is implemented in Rust and aims to provide a fast and efficient alternative with additional features, especially useful on platforms with no or limited tree cli features. Available for most platforms.
Website: https://peteretelej.github.io/tree/

Features
- Display directory structure in a tree-like format
- Control the depth of recursion (
-Lor--level) - Show full path (
-for--full-path) - No indentation (
-ior--no-indent) - Display hidden files (
-aor--all) - Include specific files matching patterns (
-Por--pattern) - Display the size of each file (
-sor--size) - Display the total size of each directory (
-Hor--human-readable) - Colorize output (
-Cor--color) - Turn Colorization off (
-nor--no-color) - Use ASCII characters for tree display (
-Aor--ascii) - List directories only (
-dor--directories) - Exclude specific files matching patterns (
-Ior--exclude) - Send output to filename with
-oflag - Do not descend directories that contain more than # entries with
--filelimitflag - List directories first before files with
dirsfirstflag - Sort output by last modification time (
-t) - Reverse sort order (
-r) - Print last modification date (
-D) - Append file type indicators (
/,*, etc.) (-F) - Omit summary report (
--noreport) - Print permissions (
-p) - Read directory listing from a file or stdin (
--fromfile)
Please feel to open PR requests in case interested in implementing some of the pending features.
Installation
Download Binaries
You can easily download binaries for different platforms from the Releases Page (Windows, MacOS, Linux).
- Download and unzip for your plaform
- If placing in $PATH, you can rename it to avoid confusing with any other
treebinaries
Build from Source
If you have Rust and Cargo installed, you can build the project by running:
# copy tree binary to a PATH directory
The resulting binary will be located at ./target/release/tree.
Windows 7 Support
For Windows 7 compatibility, use Rust 1.75 with the provided lockfile:
# restore default rust toolchain version
Usage
Usage
For example:
# Using short flags
# Using long flags
Using as Rust Crate
use ;
The library now also provides list_directory_as_string function that returns the tree output as a String instead of writing to stdout, useful when you need to capture the output for further processing.
Using the bytes_to_human_readable function to print human readable file sizes
use bytes_to_human_readable;
use fs;
Development
Contributing
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, please feel free to open an issue or submit a pull request on the GitHub repository.
Code Formatting
This project uses standard Rust formatting. Before submitting a PR:
# Format your code
# Verify formatting
# run the pre-push script to ensure code quality
Consider copying the pre-push script to your git hooks directory:
QA Testing
The project includes a comprehensive Rust-based QA testing tool in tools/qa that validates all tree CLI features across multiple platforms using Docker containers.
# Build the QA tool
&&
# Run tests on Linux platform
# Run tests on multiple platforms
# Run with verbose output for debugging
# Clean up Docker resources
The QA tool executes 34 comprehensive tests across 9 categories (basic functionality, file filtering, display options, sorting, etc.) in isolated Docker containers. Tests validate features as advertised in this README using only the generated binaries. See tools/qa/README.md for full documentation.
VS Code Settings
For VS Code users, add this to your settings.json:
Releasing a new version
Update version in Cargo.toml and push a tag:
# Update version in Cargo.toml to 1.2.3
GitHub Actions will automatically build binaries and publish to GitHub releases and crates.io.
Docs
License
MIT