Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration and CLI options: truncate owner #905

Merged
merged 1 commit into from
Sep 17, 2023

Conversation

bbc2
Copy link
Contributor

@bbc2 bbc2 commented Sep 16, 2023

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:

  • --truncate-owner-after
  • --truncate-owner-marker

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

  • Use cargo fmt
  • Add necessary tests
  • Add changelog entry
  • Update default config/theme in README (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

This adds the following CLI flags:

- `--truncate-owner-after`
- `--truncate-owner-marker`

And the following configuration fields:

```yaml
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.
@muniu-bot
Copy link

muniu-bot bot commented Sep 16, 2023

[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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov-commenter
Copy link

Codecov Report

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

❗ 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%) ⬆️
src/flags/truncate_owner.rs 95.45% <95.45%> (ø)
src/config_file.rs 72.44% <100.00%> (+0.87%) ⬆️
src/display.rs 83.23% <100.00%> (-0.55%) ⬇️
src/flags.rs 96.87% <100.00%> (+0.10%) ⬆️
tests/integration.rs 100.00% <100.00%> (ø)

... and 12 files with indirect coverage changes

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

@zwpaper zwpaper added this to the v1.1.0 milestone Sep 17, 2023
@zwpaper
Copy link
Member

zwpaper commented Sep 17, 2023

Thanks for the great work!

@zwpaper zwpaper merged commit 93b3fb0 into lsd-rs:master Sep 17, 2023
18 of 19 checks passed
@bbc2 bbc2 deleted the truncate-owner branch September 17, 2023 12:29
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.

None yet

3 participants