tree

A cross-platform directory tree utility inspired by the Unix tree command.

Screenshot of tree

tree is a cross-platform command-line utility that recursively displays the directory structure of a given path in a tree-like format. Written in Rust, it is inspired by the classic Unix tree command and adds features like pattern-based filtering, human-readable file sizes, permission display, and colour output — all in a single, portable binary.

Features

  • Recursive tree display — renders directory structures with depth control via -L/--level
  • File filtering — include or exclude files with glob patterns (-P/--pattern, -I/--exclude)
  • File sizes — display sizes in bytes (-s) or human-readable format (-H/--human-readable)
  • Colour output — colour-coded entries by file type, controllable with -C/--color and -n/--no-color
  • Permission display — show Unix file permissions with -p
  • Sort by modification time — sort entries by mtime with -t
  • Full path display — print the full path prefix for each entry with -f/--full-path
  • ASCII mode — use plain ASCII characters for the tree lines with -A/--ascii
  • Library support — usable as a Rust crate with list_directory() and list_directory_as_string() functions

Installation

cargo install rust_tree --locked

Or install from source:

git clone https://github.com/peteretelej/tree.git
cd tree
cargo build --release
# Debian / Ubuntu / Fedora
# Pre-built Linux binaries are available on the
# [releases page](https://github.com/peteretelej/tree/releases).

Usage

# Display the current directory tree
tree .

# Limit depth to 2 levels
tree -L 2 .

# Show all files including hidden, with full paths and sizes
tree -a -f -s .

# Filter to only .txt files, hiding empty directories
tree -P "*.txt" --prune .

# Human-readable sizes with colour
tree -s -H -C .

# Show permissions and sort by modification time
tree -p -t .

# ASCII-only output (useful for piping)
tree -A .