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 an option to style any string without path verification #80

Merged
merged 4 commits into from
Jan 16, 2024

Conversation

REALERvolker1
Copy link
Contributor

This pull request adds a function, LsColors::style_for_str() that retrieves the correct suffix style for any string.

It would provide a workaround for both #70 and #78, they would just have to verify that the file exists before colorizing it. Or, they could just colorize it, because that would work too.

It's pretty simple anyways. I decided not to implement this in bin.rs because I did not know if you want that or not.

Let me know if I need to revise anything. I tried to keep changes minimal, and this was literally the second rust #[test] I've ever written.

@sharkdp
Copy link
Owner

sharkdp commented Jan 16, 2024

Thank you very much for your contribution. I rebased to fix some CI issues and did a minor rewrite of the unit test — hope that's fine with you.

Regarding the lscolors binary, let's discuss potential changes in the two issues you linked above. I'm certainly open to that.

@sharkdp sharkdp merged commit 58a3069 into sharkdp:master Jan 16, 2024
48 checks passed
@nkh
Copy link

nkh commented Jan 22, 2024

@sharkdp it would be great if the option existed in the binary.

Best would be to color normally if the file exists (executable bit, ...) or just color it according to the extension otherwise.

@sharkdp
Copy link
Owner

sharkdp commented Jan 24, 2024

Can you please open a new issue with a proposal on how we would change the CLI (if necessary)?

@REALERvolker1 REALERvolker1 mentioned this pull request Jan 26, 2024
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.

3 participants