lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.05k stars 425 forks source link

Add configuration and CLI options: truncate owner #905

Closed bbc2 closed 11 months ago

bbc2 commented 11 months ago

Hello! This is my first attempt to contribute something meaningful to this project so I don't know I'm doing it right. Thank you in advance for your feedback.

This adds the following CLI flags:

And the following configuration fields:

truncate-owner:
  after:
  marker: ""

The default behavior of LSD is unchanged.

The problem this change attempts to solve is the usability of the -l flag on systems where some user or group names are long but cannot be changed (e.g. the user is not admin and the account is managed in a central directory). In such cases, even with a decently sized terminal (90+ characters wide), lines often overflow, making the directory listing hard to read.

Without this change, the only mitigation would consist in turning off the display of file ownership (via the blocks configuration field) which is unsatisfactory because ownership information is very useful.


Default settings (the length of user/group name may seem exaggerated but it's actually the same length as my user/group name on machines I have to use):

lsd_before

With --truncate-owner-after 7 --truncate-owner-marker …:

lsd_after


TODO

muniu-bot[bot] commented 11 months ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bbc2

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/lsd-rs/lsd/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
codecov-commenter commented 11 months ago

Codecov Report

Merging #905 (5ffa319) into master (762e724) will decrease coverage by 0.69%. The diff coverage is 95.45%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #905      +/-   ##
==========================================
- Coverage   86.53%   85.84%   -0.69%     
==========================================
  Files          49       50       +1     
  Lines        4848     4932      +84     
==========================================
+ Hits         4195     4234      +39     
- Misses        653      698      +45     
Files Changed Coverage Δ
src/app.rs 33.33% <ø> (ø)
src/meta/owner.rs 87.50% <93.75%> (+12.50%) :arrow_up:
src/flags/truncate_owner.rs 95.45% <95.45%> (ø)
src/config_file.rs 72.44% <100.00%> (+0.87%) :arrow_up:
src/display.rs 83.23% <100.00%> (-0.55%) :arrow_down:
src/flags.rs 96.87% <100.00%> (+0.10%) :arrow_up:
tests/integration.rs 100.00% <100.00%> (ø)

... and 12 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

zwpaper commented 11 months ago

Thanks for the great work!