sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
48.65k stars 1.23k forks source link

Option to omit binary content even when writing to a file #2927

Open max-sixty opened 5 months ago

max-sixty commented 5 months ago

I'm trying to write a repo of files all to a single file. I'd like to take advantage of bats feature to omit writing binary files.

But when piping output to a file, bat writes binary files. I think -f avoids writing binary files, but will then write colors, which I don't want.

I think it would work to have the opposite of --all (ref https://github.com/sharkdp/bat/issues/2043), which will write binary even when writing to a TTY. Possibly this synthesizes to an option of --display-binary/--skip-binary...?

domenicomastrangelo commented 3 months ago

Hi @max-sixty, could you confirm that the command you're trying to execute is similar to this:

bat * -p -A | tee output.txt

I was able to reproduce what you pointed out as the output.txt file will contain the executables in the folder.

The same output is created from cat, so I don't know if the project wants to deviate from it adding a separate feature.

If someone agrees with this feature request, I'd be happy to give it a go :)

max-sixty commented 3 months ago

Hi @max-sixty, could you confirm that the command you're trying to execute is similar to this:

bat * -p -A | tee output.txt

Yes that's correct!

The same output is created from cat, so I don't know if the project wants to deviate from it adding a separate feature.

Yes, my suggestion was a --display-binary/--skip-binary flag...

domenicomastrangelo commented 3 months ago

Yeah, i think it's a good idea. I could implement something for this if nobody has anything against it :)