Skip to content

Add Nerd Fornts icons/glyphs support#42

Merged
peteretelej merged 1 commit into
peteretelej:mainfrom
alteredeg0:feature/icons
Sep 11, 2025
Merged

Add Nerd Fornts icons/glyphs support#42
peteretelej merged 1 commit into
peteretelej:mainfrom
alteredeg0:feature/icons

Conversation

@alteredeg0

Copy link
Copy Markdown
Contributor

🎨 Add Nerd Fonts Icons/Glyphs Support

📋 Summary

This PR introduces a new --icons flag that displays Unicode icons (Nerd Fonts) alongside file and directory names in the tree output, significantly enhancing the visual experience and making it easier to identify different file types at a glance.

✨ Features

  • New CLI option: --icons flag to enable icon display
  • Comprehensive icon coverage: 100+ icons for various file types and extensions
  • Smart icon selection: Priority-based system (well-known files → extensions → generic types)
  • Custom theme support: JSON-based theme system for future extensibility
  • Full compatibility: Works seamlessly with all existing tree options

🔧 Technical Implementation

New Dependencies

  • serde with derive features for JSON serialization
  • serde_json for theme parsing

Core Components

  • IconManager: Handles icon loading and selection logic
  • Embedded default theme: 100+ icons included in binary
  • JSON theme structure: Extensible format for custom themes

Icon Categories

  1. Well-known files: readme.md 📖, dockerfile 🐳, etc.
  2. File extensions: 80+ extensions covered
    • Programming languages: Rust 🦀, Python 🐍, JavaScript 📜, etc.
    • Media files: Images 🖼️, Audio 🎵, Video 🎬
    • Documents: PDF 📕, Office docs 📘
    • Archives: ZIP 📦, etc.
  3. Generic types: Directories 📁, files 📄, executables ⚙️

📊 Usage Examples

# Basic usage with icons
tree --icons

# Combined with other options
tree --icons --color --classify

Example output:

image

❗ Impact

  • 6 files modified
  • 257 lines added, 4 lines removed
  • 1 new file (icons.rs)
  • Backward compatible: No breaking changes
  • Optional feature: Only active with --icons flag

🧪 Testing

  • All existing functionality remains unchanged
  • New feature is opt-in and doesn't affect default behavior
  • Compatible with all existing tree options (colors, classification, etc.)

🎯 Benefits

  • Enhanced UX: Visual file type identification
  • Better readability: Easier navigation in complex directory structures
  • Professional appearance: Modern, clean output with meaningful icons
  • Zero performance impact: Icons embedded in binary, no external dependencies

This enhancement makes the tree command more user-friendly and visually appealing, especially useful for developers working with diverse file types in their projects.

@peteretelej

Copy link
Copy Markdown
Owner

Thanks for this. I'll review it first chance I get

@peteretelej peteretelej added the enhancement New feature or request label Sep 8, 2025
@peteretelej
peteretelej merged commit cef5992 into peteretelej:main Sep 11, 2025
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants