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

Allow disabling color codes in the output #1490

Open
tastyminerals opened this issue Dec 18, 2024 · 4 comments
Open

Allow disabling color codes in the output #1490

tastyminerals opened this issue Dec 18, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@tastyminerals
Copy link

Summary 💡

It would be nice to have an option to disable shell color codes and make the output of onefetch easier to parse.
For example

[31;1mCommits�[0m�[39;1m:�[0m �[39m411�[0m
[31;1mChurn (17)�[0m�[39;1m:�[0m �[39m.travis.yml 6�[0m
[39m            …/workflows/build-test.yml 4�[0m

is problematic once you want to collect some stats across many repos.

Similar neofetch issue: dylanaraps/neofetch#753

Motivation 🔦

I want to collect repo summaries across many projects.

ls -d * | xargs -I {} onefetch "{}" --no-bots --no-merges --number-of-authors 10 --number-of-file-churns 3 --no-art --no-color-palette --no-bold > summary.txt

produces a file which is difficult to parse without stripping the shell color codes first.

@tastyminerals tastyminerals added the enhancement New feature or request label Dec 18, 2024
@tastyminerals tastyminerals changed the title Disable colors Disable color codes in the output Dec 18, 2024
@tastyminerals tastyminerals changed the title Disable color codes in the output Allow disabling color codes in the output Dec 18, 2024
@o2sh
Copy link
Owner

o2sh commented Dec 18, 2024

Maybe you could use this option?

  -o, --output <FORMAT>
          Outputs Onefetch in a specific format

          [possible values: json, yaml]

@spenserblack
Copy link
Collaborator

Yeah, as @o2sh said, if you're looking for something machine-readable then you might want to use -o json. That, combined with jq, can help. E.g.

onefetch -o json | jq '.infoFields[].[]'

Though it might be reasonable to reinterpret the --true-color auto|never|always argument to --color auto|true|ansi|never.

@tastyminerals
Copy link
Author

tastyminerals commented Jan 7, 2025

ok, -o json is a good workaround.
the --color never or similar option could be a nice addition since one would expect the ability to disable colorization if --color exists. But I am good with json 👍

@spenserblack
Copy link
Collaborator

If you're interested in making a PR for finer color controls, here's an example of how I implemented --color always|ansi|never: spenserblack/gengo#491.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants