bat icon indicating copy to clipboard operation
bat copied to clipboard

Option to omit binary content even when writing to a file

Open max-sixty opened this issue 1 year ago • 3 comments

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...?

max-sixty avatar Apr 04 '24 01:04 max-sixty

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

domenicomastrangelo avatar May 30 '24 08:05 domenicomastrangelo

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...

max-sixty avatar May 30 '24 15:05 max-sixty

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

domenicomastrangelo avatar May 31 '24 17:05 domenicomastrangelo