Skip to content

codingseb/stree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STREE - Directory Structure Tree

A blazing-fast Rust CLI tool for visualizing directory structures with emojis. Perfect for exploring project hierarchies, creating documentation, or piping to other tools.

Features

Fast - Written in Rust with optimizations for speed 🎨 Beautiful - Displays trees with emojis and hierarchy connectors 🔍 Flexible - Powerful filtering with regex patterns 📋 Clipboard - Copy trees directly to clipboard 📊 Stats - Get statistics about your directory structure ⏱️ Timeout - Never hang on large directories 🔗 Pipeable - Tree output goes to stdout, metadata to stderr

Installation

Binary is available in C:\cmds\stree.exe after building.

compile.bat   # Build and install to C:\cmds

Quick Start

# Show current directory structure
stree

# Recursive with folder names only
stree -r -nf

# Show PDFs in a directory
stree -r -fi ".*\.pdf$"

# Exclude node_modules and .git
stree -r -i "node_modules|\.git"

# Copy tree to clipboard
stree -r -c

# Get statistics
stree -r -s

Usage

stree [OPTIONS]

OPTIONS:
  -r, --recursive               Recursive mode (all subdirectories)
  -d, --dir <path>             Root directory (default: current)
  -i, --ignore <regex>         Ignore by name
  -ip, --ignore-path <regex>   Ignore by full path
  -fi, --filter <regex>        Show only matching files
  -fip, --filter-path <regex>  Filter files by path

  -nr, --no-root               Don't show root folder
  -nf, --no-files              Folders only
  -fo, --files-only            Files only
  -fp, --full-path             Show relative paths
  -fpr, --full-path-root       Show paths with root
  -fpa, --full-path-absolute   Show absolute paths

  -nl, --no-lines              Remove tree connectors
  -ni, --no-icons              Remove emoji icons
  -ml, --max-level <n>         Limit depth (0 = unlimited)

  -c, --clipboard              Copy to clipboard
  -co, --clipboard-only        Copy without displaying
  -ar, --align-right           Right-align tree

  -s, --stats                  Show statistics
  -so, --stats-only            Only statistics
  -v, --void                   Empty folders only

  -t, --timeout <sec>          Timeout (0 = no limit, default: 5)
  -li, --limit-items <n>       Max items (0 = unlimited)

  -h, --help                   Show help

Examples

Explore a project structure

stree -r C:\Users\YourName\Projects\MyProject

Find all TypeScript files

stree -r -fi ".*\.ts$"

Show only directories, no files

stree -r -nf

Exclude common folders

stree -r -i "node_modules|\.git|target|dist"

Get stats on a large codebase

stree -r -s -t 10

Copy tree to clipboard

# Copy and display
stree -r -c

# Copy without displaying (silent)
stree -r -co

# Copy and show statistics
stree -r -c -s

# Copy with stats only (no tree display)
stree -r -co -so

Pipe to other tools

stree -r | your-command

Output Modes

Tree Structure (stdout)

The tree goes to stdout and can be piped:

stree -r > output.txt
stree -r | grep "\.rs"

Messages (stderr)

Warnings, confirmations, and stats go to stderr and don't interfere with piping:

stree -r 2>/dev/null  # Keep only tree
stree -r 2>&1         # Keep both

Combining Clipboard and Stats Flags

Clipboard and stats flags are independent and can be combined freely:

# Tree only
stree -r                  # Display tree

# With clipboard
stree -r -c              # Tree + clipboard copy
stree -r -co             # Clipboard only (no tree display)

# With statistics
stree -r -s              # Tree + stats
stree -r -so             # Stats only (no tree display)

# Combined
stree -r -c -s           # Tree + clipboard + stats
stree -r -co -s          # Clipboard + stats (no tree)
stree -r -c -so          # Clipboard + stats only
stree -r -co -so         # Clipboard + stats only

Performance

  • Optimized binary: LTO, symbols stripped, no debuginfo
  • Smart timeouts: Prevents hanging on huge directories
  • Efficient filtering: Regex compiled once and reused
  • Streaming output: Lines printed immediately

Building

Requirements

  • Rust 1.85.0 or later

Development build

dev.bat -r

Release build (optimized)

compile.bat

Creates C:\cmds\stree.exe

Technical Details

Regex Options:

  • Case-insensitive matching
  • -i "node_modules|\.git" to ignore multiple patterns
  • -fi ".*\.pdf$" to filter file types

Path Modes:

  • -fp: Relative path (e.g., src/main.rs)
  • -fpr: Path with root (e.g., project/src/main.rs)
  • -fpa: Absolute path (e.g., C:\Users\name\project\src\main.rs)

Display Order:

  • Folders before files
  • Alphabetically sorted within each group

Statistics Include:

  • Total lines, folders, files
  • Root-level items count
  • Leaf folders (no subdirectories)
  • Empty folders count
  • Execution time

Clipboard

Full tree is copied even when:

  • Timeout is reached
  • Item limit is exceeded
  • Tree is not displayed (-co)

Why Rust?

Ported from PowerShell for:

  • Performance: ~100x faster
  • Portability: Single executable
  • Simplicity: No runtime dependencies
  • Optimization: Full LTO and stripping

Use stree -h for help.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published