Skip to content

Feature request: limit number of files shown per directory in tree mode #1188

@tal

Description

@tal

Feature Request

When using lsd --tree, directories with many files dominate the output and make it hard to get a quick overview of the directory structure. I'd love an option to limit the number of files displayed per directory (e.g., --max-items 4 or a max_items config option).

Use Case

I use lsd in tree mode to get a quick sense of what's in a folder structure. My goal is to see enough of each directory's contents to decide whether it's worth drilling into — not to see every file. When a folder has dozens or hundreds of files, the tree becomes unwieldy and the useful signal from other directories gets buried.

A truncation limit (e.g., show the first N files and then something like ... and 42 more) would let me scan the tree, spot folders with relevant-looking contents, and then explore those specifically.

Proposed Behavior

$ lsd --tree --depth 2 --max-items 4

 project/
├──  src/
│  ├──  index.ts
│  ├──  config.ts
│  ├──  utils.ts
│  ├──  router.ts
│  └──  ... (12 more)
├──  tests/
│  ├──  index.test.ts
│  └──  config.test.ts
└──  node_modules/
   ├──  express/
   ├──  lodash/
   ├──  typescript/
   ├──  eslint/
   └──  ... (847 more)

This could be a CLI flag (--max-items N) and/or a config.yaml option (max_items: N).

Prior Art

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions