Skip to content

feat: support icon matching by filename prefix - #1228

Open
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:prefix-icons
Open

feat: support icon matching by filename prefix#1228
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:prefix-icons

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Aug 7, 2026

Copy link
Copy Markdown

Closes #726

This PR adds support for matching icons by filename prefix in the icon theme.

A new prefix section can be added to an icon theme YAML file. When looking up an icon for a regular file, lsd now checks, in order:

  1. exact file name match (name)
  2. longest matching filename prefix (prefix)
  3. file extension match (extension)
  4. generic file type fallback

The longest matching prefix wins; if several prefixes have the same length, the lexicographically first one is used so the result is deterministic.

The default fancy theme maps the log prefix to the existing log icon, so rotated log files like log.lsd.0 or log.2024-01-01 are shown with the log icon instead of the generic file icon.

Example custom theme snippet

prefix:
  cargo: "📦"
  readme: "📖"

Tests

  • Unit tests for deserialization, default merging, custom entries, and longest-match tie breaking.
  • Integration test verifying that log.lsd.0 renders the log icon (\u{f18d}).

🤖 Generated with Claude Code

Add a new "prefix" section to the icon theme. A configured prefix is
matched when a file name starts with it, falling back only after an
exact name match and before an extension match. The longest matching
prefix wins; ties are broken lexicographically.

The default fancy theme now maps the "log" prefix to the existing log
icon so that rotated log files like log.lsd.0 get the same icon as
*.log files.

Includes unit and integration tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

icon theme should support icons by prefix

1 participant