Scripts2026年4月15日·1 分钟阅读

lsd — The Next Gen ls Command with Icons and Colors

lsd is a Rust-powered replacement for `ls` with Nerd-Font icons, colors, tree view, Git indicators, and sane defaults for human-readable file listings.

Introduction

ls is 50 years old and shows its age: cryptic colors, no icons, no git integration, awkward -h --size=K dance. lsd modernizes it by keeping ls's flag compatibility while adding icons (when a Nerd Font is installed), smart coloring, tree view, and per-file-type icons — all in a fast Rust binary.

What lsd Does

  • Lists directories with icons, colors, permission, size, date.
  • --tree prints a full directory tree with depth limits.
  • --blocks lets you pick which columns to display.
  • Preserves most GNU ls flags (-la, -S, -t, -r).
  • Respects .gitignore when combined with other tools.

Architecture Overview

lsd wraps the standard libc stat and readdir calls, maps file extensions to icons via a bundled table, and colors output based on type using crossterm. Sort, filter, and tree logic live in a single Rust pipeline for predictable performance on large directories.

Self-Hosting & Configuration

  • Install via brew, cargo, apt, dnf, pacman, scoop.
  • Config file ~/.config/lsd/config.yaml sets default columns, date format, indent width.
  • Icon theme ~/.config/lsd/icons.yaml maps extensions → glyphs.
  • Color theme ~/.config/lsd/colors.yaml.
  • Needs a Nerd Font in terminal for icons.

Key Features

  • GNU ls compat — muscle memory transfers.
  • Per-extension icons.
  • Tree mode without installing tree.
  • Configurable columns — size-first, date-first, etc.
  • Portable: Linux, macOS, Windows (PowerShell/WT).

Comparison with Similar Tools

  • eza (exa fork) — also Rust; slightly broader feature set (git-aware columns).
  • ls — POSIX default.
  • tree — dedicated tree viewer; lsd covers both.
  • nnn/ranger — interactive file managers, different use case.
  • bat — pager for files; complementary.

FAQ

Q: No icons showing? A: Install a Nerd Font (Hack, JetBrainsMono NF, Fira Code NF) and set it in the terminal.

Q: Git indicators? A: --blocks git column.

Q: Windows support? A: Yes, via scoop/winget; Windows Terminal recommended.

Q: Customize colors? A: Edit ~/.config/lsd/colors.yaml.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产