Skip to content

Conversation

@jeffmylife
Copy link

@jeffmylife jeffmylife commented Dec 20, 2025

Summary

Adds a new lines block that displays line counts for text files, with support for directory totals when using --total-size.

Motivation

I often want to see line counts when exploring codebases, especially in tree mode. This provides a quick overview of code volume without needing external tools like wc -l.

Example Usage

Basic line counting

lsd --blocks lines,name src/

# Tree mode without totals (directories show "-")
lsd --tree --depth 2 --blocks name,lines,size src/

# Tree mode with totals (directories show cumulative counts)
lsd --tree --depth 2 --blocks name,lines,size --total-size src/

Screenshot

Screenshot 2025-12-19 at 6 14 24 PM

TODO

  • Use cargo fmt
  • Add necessary tests
  • Update config sample file in doc/samples (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

Disclaimer

This is 99% vibe coded with Claude. Feel free to completely disregard this PR and treat this as a detailed feature request.

  - Add new 'lines' and 'lines_value' blocks to show line counts
  - Implement line counting with binary file detection (null byte check)
  - Add 10MB file size limit to prevent performance issues on large files
  - Support directory totals with --total-size flag (similar to size block)
  - Display: '-' for directories (without --total-size), binary files, and errors
  - Add comprehensive unit and integration tests (399 unit, 48 integration)
  - Update documentation (man page, config sample)
  - Follow existing code patterns (Size, INode, Links blocks)

  When --total-size is used with lines block, directories show cumulative
  line counts of all contained files, matching the behavior of the size block.

  Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jeffmylife jeffmylife requested a review from zwpaper as a code owner December 20, 2025 02:17
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.

1 participant